function admin_menu_admin_menu_output_alter(&$content) {
// Check if index menu is defined in $content and is array
if( !isset($content['menu']) || !is_array($content['menu']) )
return;
foreach ($content['menu'] as $key => $link) {
// Move local tasks on 'admin' into icon menu.
if ($key == 'admin/tasks' || $key == 'admin/index') {
$content['icon']['icon'][$key] = $link;
unset($content['menu'][$key]);
}
}
}
Undefined index: menu in admin_menu_admin_menu_output_alter() (line 612 of /var/www/sites/all/modules/admin_menu/admin_menu.module)
-
12-10-2022 - |
Question
This is the error found in admin area:
Notice: Undefined index: menu in admin_menu_admin_menu_output_alter() (line 612 of /var/www/sites/all/modules/admin_menu/admin_menu.module).
Warning:Invalid argument supplied for foreach() in
admin_menu_admin_menu_output_alter() (line 612 of
/var/www/sites/all/modules/admin_menu/admin_menu.module).
Code is:
/**
* Implements hook_admin_menu_output_alter().
*/
function admin_menu_admin_menu_output_alter(&$content) {
foreach ($content['menu'] as $key => $link) {
// Move local tasks on 'admin' into icon menu.
if ($key == 'admin/tasks' || $key == 'admin/index') {
$content['icon']['icon'][$key] = $link;
unset($content['menu'][$key]);
}
}
}
Foreach is line:612
What is the error in this code?
Thanks in advance.
La solution 2
Autres conseils
As the error says, $content['menu']
seems to be undefined, but it should be an array since you are attempting to use foreach
on it. Therefore, you would need to do something like this before using it:
$content['menu'] = array('value1', 'value2');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow