Is there any function in Drupal like get_module_info('MODULE_NAME')
or I should parse info
file?
-
What module info do you want to get? – googletorp Oct 01 '10 at 11:21
-
I've been developing a module which sorts out information on existing modules and return information based on info file. – sultan Oct 01 '10 at 11:26
-
I think It would be great if there any implementation on this kinda get_info('module OR theme', 'MODULE NAME or THEME NAME') – sultan Oct 01 '10 at 11:34
-
If you don't tell what info you would like an API to give you, it's quite hard to help you. – googletorp Oct 01 '10 at 11:53
3 Answers
drupal_parse_info_file()
is the closest function, but it takes a file path, not a module name, so you have to convert the name into the path first:
$path = drupal_get_path('module', $name) . '/' . $name . '.info';
$info = drupal_parse_info_file($path);

- 28,547
- 16
- 75
- 90

- 3,530
- 18
- 17
A somewhat easier method (drupal 7 and up) is to use the system_get_info function.

- 921
- 7
- 6
If you happen to be using the Features module, it has created a solid structure for interacting with the System table that is readily adaptable for any module info gathering.
To get information about a module, use features_get_modules($module_name)
. This dispatches a module-specific request to features_get_info()
on line 475 of features.module.
The information is cached, and you can make use of hook_system_info_alter() to modify the values you need. Note that this functionality is not touched by anything in Drupal core, and is only useful for your own custom module functionality.

- 4,144
- 21
- 25