admin / build / modulesのようにDrupalでモジュールリストを取得するにはどうすればよいですか?
6 に答える
コマンドを使用drush pm-list --type=Module --status=enabled
して、インストールされているモジュールのリストを取得できます。
その他のオプションについては、http://www.drupaltonight.com/drupal-articles/using-drush-get-list-enabled-modulesを確認してください。
「 Drush 」をインストールします(どのような場合でも、慣れれば気に入るはずです)。インストールされているすべてのモジュールのテーマを一覧表示する組み込みコマンドがあります。
モジュールのリストを表示して他の場所に表示する必要がある場合(これはセキュリティの問題になる可能性があります!)、drushがどのように実行するかを調べることができます(pm.drush.inc:218)。
さらにコア機能もありますが、これが欲しいのかわかりません。
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
使用可能なすべてのモジュールを一覧表示する場合は、Drupal6またはDrupal7のいずれかで機能するはずです。
<?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;
?>
次のコマンドを使用して、特定のモジュールを検索することもできます。モジュールリストからコマースモジュールのみをリストダウンしたい場合
drush pml | grep commerce
Windowsマシンでは、grepを使用できません。したがって、findstrを使用する必要があります
drush pml | findstr commerce
次のコマンドが機能し、使用可能なすべてのモジュールのリストと、それらが含まれるパッケージ、ステータス、およびバージョンが出力されます。
drush pm-list --type=Module --status=enabled