We've Always Got Something to Say.

Read our thoughts on what's happening in the industry.

January 25 , 2012

Drupal – How to Get a List of your Active Modules

by

Has a client ever asked you “So what Drupal modules are we using?”  Now you can give them a nice table!  With links to each module page.

It will look like this:

  1. Go to http://yoursite.com/admin/modules
  2. Run the following javascript in your Console (Firebug, Developer Tools, etc – F12)
(function($, D, boxid){ /*--start--*/var $checkboxes = $(':checkbox')
    , $checked = $checkboxes.filter(':checked')
	, $dom_render_to_div = false
	;
    console.log($checked.length, 'enabled modules');

// clear old version
$('#'+boxid).remove();

var render = function(o, renderfn){
	renderfn(o);
};
var render_to_console = function(o){
	console.log(o.i, 'Section:' + o.s, 'Module:' + o.l, o.v);
};
var render_to_div = function(r){
	if( false === $dom_render_to_div ){
		var $container = $('<div id="' + boxid + '" class="debug"><h3>Active Modules</h3></div>');
		$container.append('<table></table>').append('<div class="clearfix">Copy Above</div>');
		$container.css({
			'background-color': '#FFFFFF'
			, 'left': '20%'
			, 'padding': '5%'
			, 'position': 'absolute'
			, 'top': '20%'
		});

		$('body').append($container);
		$dom_render_to_div = $container.find('table');
		$dom_render_to_div.append('<tr><th>i</th><th>Section</th><th>Label</th><th>Version</th></tr>');
	}
	$dom_render_to_div.append('<tr><td>' + r.i + '</td><td>' + r.s + '</td><td><a href="http://drupal.org/project/' + r.id + '">' + r.l + '</a></td><td>' + r.v + '</td></tr>');
};

$checked.each(function(i,o){
	var $o = $(o);
	var $row = $o.parents('tr');
	var section = $o.parents('fieldset').find('legend').text();
		if( 7 == D ) section = section.replace(/Hide /i, '');
	var label = "" + $row.find('td:nth(1) label').text();
	var version = $row.find( 7 == D ?'td:nth(2)' : 'td.version' ).text();
	var iden = $row.find(':checkbox').attr('name').match(/\]\[([^\]]+)\]/)[1];

	var row = {"i": i, "s": section, "l": label, "v": version, "id": iden};

	render(row, render_to_div);
});
/*--end--*/ })(jQuery, 7, 'module-list-debug');

About the Author

Jeremy Schwartz is a software developer with a broad range of programming experience from research, consulting, and academic settings. His favorite thing to do is refactor inefficient code into well-documented, elegant solutions using content-management systems and custom code. Or read books. Lots of books.

Leave a Reply

 

In a Nutshell

Since 1998, Atlantic BT has been a full service web development company that offers the tools, resources and services to get your business moving. We focus on combining new ideas, specific requirements, and years of experience into high-quality, results-oriented web solutions for small to medium sized businesses. If you want the best website possible that generates real results, let's get started.

Atlantic Business Technologies, Inc.
4509 Creedmoor Road, 3rd Floor
Raleigh, North Carolina 27612
  • Pinnacle Business Award Winner
  • Triangle Business Journal's Top 40 Under 40
  • Yahoo Search Marketing Ambassador
  • Google Adwords Qualified Company