如何在 admin / build / modules 中获取Drupal中的模块列表?
答案 0 :(得分:47)
您可以使用drush pm-list --type=Module --status=enabled
命令获取已安装模块的列表。
如需更多选项,请查看http://www.drupaltonight.com/drupal-articles/using-drush-get-list-enabled-modules
答案 1 :(得分:8)
安装“Drush”(无论如何,一个好的选择,一旦你习惯它,你会喜欢它)。它有build in command列出所有已安装的模块主题。
如果您需要查看模块列表以在其他地方显示它(这可能是一个安全问题!),您可以查看drush的执行方式(pm.drush.inc:218)。
此外还有core function,但我不知道这是否是你想要的。
答案 2 :(得分:1)
module_list($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE, $fixed_list = NULL)
以下是更多详情。 http://api.drupal.org/api/drupal/includes!module.inc/function/module_list/7
答案 3 :(得分:1)
如果你想列出所有可用的模块,这应该适用于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;
?>
答案 4 :(得分:1)
您还可以使用以下命令搜索特定模块。 如果您只想从模块列表中列出商业模块而不是
drush pml | grep commerce
在Windows机器上你不能使用grep。所以你必须使用findstr
drush pml | findstr commerce