sultan
sultan

Reputation: 6058

Drupal 7: how to get the modules list

How to get the modules list in Drupal as in admin/build/modules?

Upvotes: 23

Views: 31766

Answers (6)

Gokul N K
Gokul N K

Reputation: 2458

You can use drush pm-list --type=Module --status=enabled command for getting a list of installed modules.

Upvotes: 51

DrColossos
DrColossos

Reputation: 12998

Install "Drush" (a good option in any case, once you get used to it, you'll love it). It has a build in command to list all installed modules themes.

If you need to see the list of modules to display it elsewhere (this can be a security issue!), you can look into the way how drush does it (pm.drush.inc:218).

Furthermore there is a core function, but I don't know if this is what you want.

Upvotes: 9

Dev
Dev

Reputation: 212

The following command will work, outputing list of all available modules along with the package they fall in, status and version.

drush pm-list --type=Module --status=enabled

Upvotes: 1

Firoz Sabaliya
Firoz Sabaliya

Reputation: 653

You can also use following commands to search specific modules. If you want to list-down only commerce module from module list than

drush pml | grep commerce

On windows machine you cant use grep. So you have to use findstr

drush pml | findstr commerce

Upvotes: 1

jerdiggity
jerdiggity

Reputation: 3665

If you want to list all the modules available to you, this should work with either Drupal 6 or Drupal 7:

<?php
// include_once('.' . base_path() . drupal_get_path('module', 'system') . '/system.admin.inc');
// Above line was intentionally commented out (see below).
$drupal_version = (int) VERSION;
$list_modules_function = '';
if ($drupal_version >= 7 && $drupal_version < 8) {
  $list_modules_function = 'system_rebuild_module_data';
}
else if ($drupal_version >= 6 && $drupal_version < 7) {
  $list_modules_function = 'module_rebuild_cache';
}
if (empty($list_modules_function)) {
  $output = t('Oops... Looks like you are not using either version 6 or version 7 of Drupal');
}
else if (!function_exists($list_modules_function)) {
  $output = t('Oops... Unable to find the function !function(). Try uncommenting the top line of this code.', array('!function' => $list_modules_function));
}
else {
  $output = "<dl>\n";
  $list_modules = $list_modules_function();
  foreach ($list_modules as $module) {
    $output .= "<dt>" . check_plain($module->info["name"]) . "</dt>\n";
    $output .= "<dd>" . check_plain($module->info["description"]) . "</dd>\n";
  }
  $output .= "</dl>\n";
}
print $output;
?>

Upvotes: 1

Kandinski
Kandinski

Reputation: 983

module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE, $fixed_list = NULL)

Here are more details. http://api.drupal.org/api/drupal/includes!module.inc/function/module_list/7

Upvotes: 1

Related Questions