21

Is there a way of having a list of all the used (active) modules on a site ?

I am in the process of documenting a site and would like to list all the active modules, I know I can take them from admin/modules but there must be another way.

10 Answers 10

33

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

If you want to exclude the core modules use drush pm-list --type=Module --no-core --status=enabled

  • As mentionned on a related post you may list all of them for a multi-site environment with @sites by doing drush @sites pml --no-core --type=module --status="enabled" -y and filter on say some_module using grep ` | grep some_module` – MediaVince Jul 11 '18 at 10:32
21

The two options I use are Drush and a custom script.

For Drush, you can use drush pm-list:

$ drush help pm-list
Show a list of available extensions (modules and themes).

Options:
 --type                                    Filter by extension type. Choices:
                                           module, theme.
 --status                                  Filter by extension status. Choices:
                                           enabled, disable and/or 'not
                                           installed'. You can use multiple
                                           comma separated values. (i.e.
                                           --status="disabled,not installed").
 --package                                 Filter by project packages. You can
                                           use multiple comma separated values.
                                           (i.e. --package="Core -
                                           required,Other").
 --core                                    Filter out extensions that are not
                                           in drupal core.
 --no-core                                 Filter out extensions that are
                                           provided by drupal core.
 --pipe                                    Returns a space delimited list of
                                           the names of the resulting
                                           extensions.


Aliases: pml

I also wrote this script for Drupal 6. You need to edit the bootstrap for Drupal 7, and you may also want to tweak the path checking. I put this in a file called modules.php in my DOCROOT and add access restriction around it to prevent it from being called from the wild.

<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
header('Content-Type: text/plain');

$files = drupal_system_listing('/\.module$/', 'modules', 'name', 0);

system_get_files_database($files, 'module');

ksort($files);

$core_installed = array();
$core_enabled = array();
$core_disabled = array();

$contrib_installed = array();
$contrib_enabled = array();
$contrib_disabled = array();

foreach ($files as $info) {
  $filename = $info->filename;
  $name = $info->name;
  $status = $info->status;

  $contrib = strpos($filename, "sites/all/modules/") === 0;

  if ($contrib) {
    $contrib_installed[] = $name;
    if ($status) $contrib_enabled[] = $name;
    else $contrib_disabled[] = $name;
  } else {
    $core_installed[] = $name;
    if ($status) $core_enabled[] = $name;
    else $core_disabled[] = $name;
  }
}

print "Installed Core Modules: " . join(", ", $core_installed) . "\n\n";
print "Enabled Core Modules: " . join(", ", $core_enabled) . "\n\n";
print "Disabled Core Modules: " . join(", ", $core_disabled) . "\n\n";

print "Installed Contrib Modules: " . join(", ", $contrib_installed) . "\n\n";
print "Enabled Contrib Modules: " . join(", ", $contrib_enabled) . "\n\n";
print "Disabled Contrib Modules: " . join(", ", $contrib_disabled) . "\n\n";

This script can be called with drush using: drush scr modules.php

7

The Enabled Modules (enabled_modules) module provides lists of all enabled modules on a website.

Or,

You can use this API function module_list to get all enabled modules.

4

Yes, check the Module Filter module: It's excellent administrator helper that makes managing modules much easier.

The modules list page can become quite big when dealing with a fairly large site or even just a dev site meant for testing new and various modules being considered. What this module aims to accomplish is the ability to quickly find the module you are looking for without having to rely on the browsers search feature which more times than not shows you the module name in the 'Required by' or 'Depends on' sections of the various modules or even some other location on the page like a menu item.

When tabs is enabled via the Module Filter's settings page, a new module layout theme is implemented. This tab layout provides a tab for each package as well as a tab that will show every module alphabetically. The filter textfield is available on each tab but currently doesn't support autocomplete.

2

Drush make has a primitive makefile generation capability. To use it, simply change your directory to the Drupal installation from which you would like to generate the file, and run the following command:

drush generate-makefile /path/to/make-file.make

You get make-file.make with a list of modules. Then you can load these modules in other project. Read http://www.drush.org/en/master/make/#usage

2

If you don't have commandline access to run drush, you might be looking for something you can do from the Web UI. The best solution I could find was browsing to the Modules page and then running this command in the console:

jQuery('table.sticky-enabled input[checked=checked]')
  .closest('tr')
  .find('td label strong')
  .each(function() {
    console.log(jQuery(this).text());
})

This will print all the enabled modules in the console, where you can copy paste them anywhere you'd like.

2

The simplest way I've found is a database query you could put in a custom module or Drush script to output it in a format you want.

$enabled_modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND status = 1"); print implode("\n", $enabled_modules);

2

Install and enable the Forena module (disclosure I'm a co-maintainer). Users with role "administrator" will then be able to navigate to the delivered (sample) report located at reports/drupaladmin.enabled_contributions, which will give you the list this question is about.

Here is how the specification (.FRX file, an XHTML document) to create the report looks like:

<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY nbsp "&#160;">
]>
<html xmlns:frx="urn:FrxReports">
<head>
<title>Enabled Modules and Themes</title>
<frx:category>Drupal Administration</frx:category>
<frx:options hidden="0" />
<frx:parameters>
</frx:parameters>
<frx:docgen>
</frx:docgen>

</head>
<body>
  <div frx:block="drupal/enabled_modules" id="forena-1">
    <table>
      <thead>
        <tr>
          <th>name</th>
          <th>owner</th>
          <th>weight</th>
        </tr>
      </thead>
      <tbody>
        <tr frx:foreach="*" id="forena-2">
          <td>{name}</td>
          <td>{owner}</td>
          <td>{weight}</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>

And here is how the data block (SQL statement) referred to in the report looks like:

--ACCESS=access administration pages
SELECT name, owner, weight FROM {system}
WHERE status=1 AND 'module'=type
ORDER BY name

That's really "it".

PS: feel free to tune (adapt) the .FRX file and/or the data block to fit your own needs.

  • AND 'module'=type?! Should be AND type = 'module' – ajmedway Oct 29 '18 at 10:35
  • @ajmedway you're probably right, why not "suggest an edit"? I'd be happy to approve it ... – Pierre.Vriens Oct 29 '18 at 11:16
  • It's not a big deal I suppose - the clause works. It's just not conventional to have the column name on the right-hand side of the expression with the value on the left. – ajmedway Oct 29 '18 at 11:22
0

For those without drush: go to modules page, with module filter enabled (not absolutely necessary, but good for formatting).

Then show source page, copy modules html inside "<"table>" to "<"/table>. Paste into gedit, wrap some html around it (html, body), and you'll have a html page, including indication of unused/disabled modules (showing check box unchecked) which can be important when rebuilding a site (insofar as the disabled modules might be needed, or can be installed -> uninstalled for the sake of cleaning up the database)

0

Schema module is one option while Views can do the trick too although without the additional Views System module, which i found buggy, you dont get version numbers.

  • The OP needs the list of the enabled modules, not their schema version. – kiamlaluno Jan 26 '15 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.