Drupal 7:如何获取模块列表

发布于 2024-10-03 20:20:32 字数 70 浏览 1 评论 0原文

如何获取 Drupal 中的模块列表(如 admin/build/modules 中所示)?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

韬韬不绝 2024-10-10 20:20:33

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

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

此外还有一个核心函数,但我不知道这是否是你想要的。

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.

扛刀软妹 2024-10-10 20:20:33
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

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

征棹 2024-10-10 20:20:33

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

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;
?>
少钕鈤記 2024-10-10 20:20:33

您还可以使用以下命令来搜索特定模块。
如果您只想从模块列表中列出商务模块,那么

drush pml | grep commerce

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

drush pml | findstr commerce

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
雨的味道风的声音 2024-10-10 20:20:33

以下命令将起作用,输出所有可用模块的列表以及它们所属的包、状态和版本。

drush pm-list --type=Module --status=enabled

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
泪之魂 2024-10-10 20:20:32

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文