Drupal – List contributed modules in a page

Need to show to the cyber-world what contributed modules are you using in your beatiful Drupal 7 website? Nothing could be easier!

First of all you need to make sure to have the module “PHP filter” enabled.

Then, configure it to be used by the admin – yep, authors, editors, etc, MUST put their hand off the PHP ;) – checking “Administrator” under Roles, on the filter configuration page: admin/config/content/formats/php_code.

After that, you can select “PHP code” in the article’s text format and put the following code:

  $results = db_select('system', 's')
      ->fields('s', array('filename', 'name', 'info'))
      ->condition('s.status', 1)
      ->condition('s.type', 'module')
      ->condition('s.filename', db_like('sites/all/') . '%', 'LIKE')
      ->orderBy('s.name', 'ASC')

  $rows = array();
  foreach($results as $key => $val) {
    $info = unserialize($val->info);
    $val_filename_exploded = explode('/', $val->filename);
    $rows[$val_filename_exploded[3]] = array(
  $count = count($rows);
  $output = '<p>' . format_plural($count, '1 contributed module installed.', '@count contributed modules installed.') . '</p>';
  $output .= theme('table', array(
      'header' => array('NAME', 'MACHINE NAME', 'VERSION', 'DESCRIPTION'),
      'rows' => $rows,
      'empty' => t('No contributed modules installed.'))
  print $output;

You can see a working example here: http://dev-views-slideshow-j360.gotpantheon.com.

Thanks to abhishek.

In order to use Disqus to comment out you have to accept the use of third-party cookies.