Drupal - How to add module to admin/config page?
If you do it like this, with the system.module callback for the parent item, you get the nice listing page when you visit 'admin/config/mymodule'
/**
* Implements hook_menu().
*/
function MYMODULE_menu() {
$items = [];
$items['admin/config/mymodule'] = [
'title' => 'My configuration section',
'description' => 'This is the parent item',
'position' => 'left',
'weight' => -100,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => ['administer site configuration'],
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
];
// Need at least one child item before your section will appear.
$items['admin/config/mymodule/item'] = [
'title' => 'First item',
'description' => 'This is the first child item in the section',
'page callback' => 'mymodule_item_callback',
'access arguments' => ['administer site configuration'],
];
return $items;
}
Looking at the code of system_admin_config_page(), which is page callback for admin/config, I notice it contains the following lines:
if ($admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin/config' AND module = 'system'")->fetchAssoc()) {
$result = db_query("
SELECT m.*, ml.*
FROM {menu_links} ml
INNER JOIN {menu_router} m ON ml.router_path = m.path
WHERE ml.link_path != 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $item) {
_menu_link_translate($item);
if (!$item['access']) {
continue;
}
// ...
}
// ...
}
The first query select the menu_name field for the menu associated with the path admin/config, which by default is management; the second query select all the menus that have the same value for menu_name, and whose parent is admin/config.
As your menu uses a different value for menu_name, it is not selected from the second query, and it is not show in the admin/config page.
Remove the 'menu_name' part, that is not necessary.