Drupal 7: how to get the modules list
Asked Answered
R

6

23

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

Radbourne answered 20/11, 2010 at 9:48 Comment(1)
From @Gokul: drush pm-list --type=Module --status=enabledGrivet
S
9

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.

Somersomers answered 20/11, 2010 at 10:55 Comment(9)
I need to display the list of modules and themes in a web interface to make possible user to select themes and modulesRadbourne
Then why can't you use the build/modules view for it? Or are you talking about simply displaying it without any other functions?Somersomers
I am new to build/modules how to use it? )Radbourne
It's your path given from above (I just omitted the admin part for lazyness ;))Somersomers
So you mean there is no inner functions supported and I should to code this on my own?Radbourne
What are you even trying to do? Log into the admin and enable/disable modules and themes. There is no need for programming it.Populace
I've developing scaling toolkit pack for a drupal sites so the admin user can easily scale and create new sub-sites and sub-domains of drupal sites thats why I need to provide theme/module selection...Radbourne
Solution already found. Achieve this using system_modules function as an argument to a drupal_get_form functionRadbourne
This defined at modules/system.module:313-320Radbourne
S
51

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

Sorensen answered 8/1, 2012 at 8:6 Comment(1)
Googled for this and ended up using my own answer which I had submitted 2 years back :)Sorensen
S
9

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.

Somersomers answered 20/11, 2010 at 10:55 Comment(9)
I need to display the list of modules and themes in a web interface to make possible user to select themes and modulesRadbourne
Then why can't you use the build/modules view for it? Or are you talking about simply displaying it without any other functions?Somersomers
I am new to build/modules how to use it? )Radbourne
It's your path given from above (I just omitted the admin part for lazyness ;))Somersomers
So you mean there is no inner functions supported and I should to code this on my own?Radbourne
What are you even trying to do? Log into the admin and enable/disable modules and themes. There is no need for programming it.Populace
I've developing scaling toolkit pack for a drupal sites so the admin user can easily scale and create new sub-sites and sub-domains of drupal sites thats why I need to provide theme/module selection...Radbourne
Solution already found. Achieve this using system_modules function as an argument to a drupal_get_form functionRadbourne
This defined at modules/system.module:313-320Radbourne
S
1
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

Sayer answered 5/3, 2013 at 20:40 Comment(0)
W
1

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;
?>
Whopper answered 29/4, 2013 at 8:44 Comment(2)
can you explain what is t() here? I am getting Fatal error: Call to undefined function t() errorTheologue
t() is a function used for several purposes, but its primary purpose is to translate text. See this API documentation for more information.Whopper
M
1

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
Moor answered 1/4, 2015 at 6:6 Comment(0)
B
1

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
Bradbradan answered 1/5, 2015 at 7:18 Comment(2)
Not nice to copy the answer from one of the comments ;)Accrue
Just used it, and it worked for me. I don't have enough reputations to +1 any comment or question, so I think writing what worked for me will support the solution... :p :DBradbradan

© 2022 - 2024 — McMap. All rights reserved.