开发者

Drupal 7: how to get the modules list

开发者 https://www.devze.com 2023-01-26 15:40 出处:网络
How to get the modules list in Drupal as in admin/build/mo开发者_运维知识库dules?You can use drush pm-list --type=Module --status=enabled command for getting a list of installed modules.Install \"Drus

How to get the modules list in Drupal as in admin/build/mo开发者_运维知识库dules?


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


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.


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


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;
?>


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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消