5

I use Drush to enable and disable module, to do this I need to know the machine name of the module.

At /admin/modules I can see the list of modules, but this list doesn't show the machine name, jut the human readable name.

I created a view to list the machine name of modules but I'd like to have it at /admin/modules. Is there any way to do this?

  • The folder name will always be the machine name. – GoodSp33d Jul 4 '12 at 11:42
  • incorrect. The machine name is the .info's filename. – jonhattan Jul 7 '12 at 16:19
3

If you don't mind going low-tech you can just look at the value of the checkbox next to each module; it contains a string like:

modules[Core][aggregator][enable]

In that example, aggregator being the machine name of the module.

If you don't want to go low-tech you'll need to implement hook_form_alter(), loop through the module data in the form and add the machine name somewhere.

For example, the following code will add the machine name in brackets after the title of each module:

function MYMODULE_form_system_modules_alter(&$form, &$form_state, $form_id) {
  foreach (element_children($form['modules']) as $group_key) {
    foreach (element_children($form['modules'][$group_key]) as $module_key) {
      $machine_name = " ($module_key)";
      $form['modules'][$group_key][$module_key]['name']['#markup'] = $form['modules'][$group_key][$module_key]['name']['#markup'] . $machine_name;
    }
  }
}

Screenshot of the results on a blank Drupal installation:

enter image description here

  • I´ll try to implement hook_form_alter(). – chefnelone Jul 4 '12 at 11:18
  • I've just updated the answer with an example, turns out it's fairly easy :) – Clive Jul 4 '12 at 11:22
  • i get this error (one for each module) Notice: Undefined index: name en utilities_form_system_modules_alter() (line 14 of...). Line 14 is: $form['modules'][$group_key][$module_key]['name']['#markup'] = $form['modules'][$group_key][$module_key]['name']['#markup'] . $machine_name; – chefnelone Jul 4 '12 at 12:18
  • The code is for Drupal 7...are you using Drupal 6 by any chance? – Clive Jul 4 '12 at 12:24
  • no, I'm using D7. Do you want me to dpm some values and paste them here? – chefnelone Jul 4 '12 at 12:33
2

Try the development snapshot of the Module Filter module. It overrides the entire modules page and displays the machine name below the human name.

The modules list page can become quite big when dealing with a fairly large site or even just a dev site meant for testing new and various modules being considered. What this module aims to accomplish is the ability to quickly find the module you are looking for without having to rely on the browsers search feature which more times than not shows you the module name in the 'Required by' or 'Depends on' sections of the various modules or even some other location on the page like a menu item.

  • Module Filter module is great stuff (shame on me, I didn't know about it). But I cannot see any machine names. Is there something that needs to be configured? – BetaRide Jul 4 '12 at 13:33
  • The code isn't present in 1.6. You have to use the 2.x-dev version. – aweizd Jul 4 '12 at 13:58
2

FYI you can get the same info with drush pm-list, you can even filter extensions by status or other criteria.

Also, to see the extension's description and dependencies use for example drush pm-info views_ui.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.