2010-11-20 62 views

回答

7

安装“Drush”(在任何情况下,一个很好的选择,一旦你习惯了它,你一定会喜欢它)。它有一个build in command列出所有已安装的模块主题。

如果您需要查看模块列表以将其显示在别处(这可能是一个安全问题!),您可以查看drush如何执行(pm.drush.inc:218)。

此外,还有一个core function,但我不知道这是不是你想要的。

+0

我需要在web界面来显示模块和主题的列表,以可能的用户选择的主题和模块 – sultan 2010-11-20 11:03:36

+0

那么为什么你不能使用build/modules视图呢?或者你是否在简单地显示它而没有任何其他功能? – DrColossos 2010-11-20 11:10:26

+0

我是新来建立/模块如何使用它? ) – sultan 2010-11-20 11:25:45

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

你能解释一下在那儿?我遇到致命错误:调用未定义的函数t()error – sheetal 2017-04-29 05:39:29

+0

t()是一种用于多种用途的函数,但其​​主要用途是翻译文本。有关更多信息,请参阅此[API文档](https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7.x)。 – jerdiggity 2017-04-30 06:32:23

0

您还可以使用下面的命令来搜索特定的模块。 如果要列出下只能从模块列表商务模块比

drush pml | grep commerce 

的Windows计算机时,你不能使用grep。所以,你必须使用FINDSTR

drush pml | findstr commerce 
1

以下命令将工作,与他们坠入,状态和版本的包一起outputing所有可用的模块列表。

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

不好意思,从一个评论复制答案;) – Peanut 2015-05-01 07:23:01

+0

刚刚使用它,它为我工作。我没有足够的声誉来+1任何评论或问题,所以我认为写什么对我有用将支持解决方案...:p:D – 2015-05-01 11:06:23