php Drupal:如何获取模块列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4232113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:21:17  来源:igfitidea点击:

Drupal: how to get the modules list

phpdrupalmoduledrupal-modules

提问by sultan

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

如何在admin/build/modules 中获取 Drupal 中的模块列表?

采纳答案by DrColossos

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

安装“ Drush”(在任何情况下都是一个不错的选择,一旦你习惯了它,你就会爱上它)。它有一个内置命令来列出所有已安装的模块主题。

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).

如果您需要查看模块列表以在其他地方显示它(这可能是一个安全问题!),您可以查看 drush 是如何做到的 (pm.drush.inc:218)。

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

此外还有一个核心功能,但我不知道这是否是您想要的。

回答by Gokul N K

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

您可以使用drush pm-list --type=Module --status=enabled命令获取已安装模块的列表。

For further options, please check out http://www.drupaltonight.com/drupal-articles/using-drush-get-list-enabled-modules

如需更多选项,请查看http://www.drupaltonight.com/drupal-articles/using-drush-get-list-enabled-modules

回答by Kandinski

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

这里有更多细节。 http://api.drupal.org/api/drupal/includes!module.inc/function/module_list/7

回答by jerdiggity

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

如果你想列出所有可用的模块,这应该适用于 Drupal 6 或 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;
?>

回答by Firoz Sabaliya

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

在 Windows 机器上你不能使用 grep。所以你必须使用 findstr

drush pml | findstr commerce

回答by Dev

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