How to override the mmenu programmatically?
Last updated on
30 April 2025
Enables or disables mmenu:
function hook_mmenu_alter(&$mmenus) {
$mmenus['mmenu_left']['enabled'] = FALSE;
}
Enables or disables mmenu by conditions:
function hook_mmenu_alter(&$mmenus) {
// Disables left mmenu on some specific pages.
if (arg(0) == 'admin') {
$mmenus['mmenu_left']['enabled'] = FALSE;
}
}
function hook_mmenu_alter(&$mmenus) {
// Disables left mmenu on some specific themes.
global $theme;
if ($theme == 'seven') {
$mmenus['mmenu_left']['enabled'] = FALSE;
}
}
Changes the assigned blocks:
function hook_mmenu_alter(&$mmenus) {
// Resets the blocks to be empty.
$mmenus['mmenu_left']['blocks'] = array();
// Assigns new one.
$mmenus['mmenu_left']['blocks'] = array(
array(
'title' => t('Management'),
'module' => 'system',
'delta' => 'management',
'collapsed' => FALSE,
'wrap' => FALSE,
'menu_parameters' => array(
'min_depth' => 2,
),
);
}
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion