Using module_list() to show active Drupal modules

This code can be used in a custom module, a template.php file, or most easily in a block. This looks good in the header bar on a demo site, without a title, as you can see in the screenshot! The reason I am using this is because I do a lot of Drupal demos and it's great to have the active modules showing so there is no question of what's required to do whatever it is I am showing. The list of modules is ordered by weight, then filename, which makes it easy to determine if your custom modules are running at the right times.

<?php
  $modules = implode(', ', module_list());
  print '<font style="font-size: 9px; line-height: 18px;">';
  print "<strong>Active Modules: </strong>{$modules}</font>";
?>
Screenshot of the block displayed in the sites header region

Screenshot of the block displayed in the sites header region

 
Tags: 

Comments

I tried this in a block and this is what I get displayed to the user. I have the php filter in use and am using drupal 7.10

'; print "Active Modules: {$modules}"; ?>

Sharon, It sounds like you probably have a syntax error in your code... maybe you can pastebin your code and post a link here?

Add new comment