After porting my theme to the latest version of zen 7.x-3.x I got this Notice every page:
Notice: Undefined index: in zen_preprocess_page() (line 227 of /local/drupal-7/sites/all/themes/zen/template.php).
The functions code is this, the last line is 227
function zen_preprocess_page(&$variables, $hook) {
// Find the title of the menu used by the secondary links.
$secondary_links = variable_get('menu_secondary_links_source', 'user-menu');
$menus = menu_get_menus();
$variables['secondary_menu_heading'] = $menus[$secondary_links];
}
I found out, that the error only occurs, when I disable the secondary menu under Structure>Menus>Settings
If you can reproduce it, I think this is a major issue.
Comment | File | Size | Author |
---|---|---|---|
#16 | 1084504-16-menu-php-error.patch | 735 bytes | JohnAlbin |
#14 | menu-bugs.patch | 1.54 KB | Crossfeed |
#7 | secondary-menu-bug-1084504-7.patch | 2.31 KB | Crossfeed |
#5 | secondary-menu-bug-1084504-5.patch | 1.45 KB | Crossfeed |
Comments
Comment #1
Foxhaven CreditAttribution: Foxhaven commentedI had the same issue (Secondary menu turned off, "Rebuild theme registry on every page" turned off). Tried re-enabling secondary menu, still had warning.
Turned on "Rebuild theme registry on every page", got rid of warning.
Turned rebuild registry off, no warning.
Cleared cache, turned secondary off & on and fiddled with performance settings... no warning.
In fact, after rebuilding the theme registry that once (with the Mar 2nd 7.x-3.x-dev) I have not been able to duplicate this issue.
My take on it is that the theme registry set from the previous 7.x-3.x-dev didn't like whatever changes came down on Mar 2nd.
Try clearing the cache and rebuilding the registry and let us know if you still get that warning.
Comment #2
Crossfeed CreditAttribution: Crossfeed commentedIn my zen sub-theme "rebuild registry on every page" is enabled. Now I tried cleaning the cache but still got that warning.
This error also occurs when I activate the Zen base theme.
Comment #3
komal.savla CreditAttribution: komal.savla commentedHi,
I was able to reproduce the same isssue on my local site.
And it seems like when we disable the secondary links, $secondary_menu_heading is not set/is empty , so the warning of Undefined index comes up.
I added the following if statements in my template.php and page.tpl.php and it worked for me.
Now I dont get any warning message.
Following are the changes that i have made:
In zen/template.php on line no 227
And in page.tpl.php
Comment #4
Crossfeed CreditAttribution: Crossfeed commentedThis fixes the issue.
I am at the very beginning of Git migration and failed to make a patch out of it. I will continue and try later.
If someone is quicker he can also patch this.
Comment #5
Crossfeed CreditAttribution: Crossfeed commentedFinally got it, but I was not able to push the changes to origin
Comment #6
komal.savla CreditAttribution: komal.savla commentedHi,
I came across this issue http://drupal.org/node/1085790 . The issue mentioned on this link is similar to this issue.
So the code which i have mentioned above i.e #3 has to be modified a bit so that both the issues are solved.
Here is the code that has to be modified in template.php
Comment #7
Crossfeed CreditAttribution: Crossfeed commentedJust modified the patch to match your code
Comment #8
essbee CreditAttribution: essbee commentedPatch worked for me.
Comment #9
Jens Peter CreditAttribution: Jens Peter commentedI have attached the patch and still have the error. I have tried flush the cash, mark second menu as active and not active, rebuild and not rebuild... and no matter what I do, I get the same error...
Please help.
I even tried to replace the ZEN with the older version but that didn't help as it was like Drupel already had seen the new version. I don't know how to uninstall the ZEN theme to correctly replace it with the older, working version.
Comment #10
Crossfeed CreditAttribution: Crossfeed commentedFor deinstallation, you have to deactivate the Theme and set a standard theme as default. Then you might delete the Zen folder in sites/all/themes/
I just installed a clean drupal7 with Zen (Starterkit Theme) and the latest patch from above. I don't get any trouble with this issue, patch works.
Comment #11
MustangGB CreditAttribution: MustangGB commentedFatal error: Call to undefined function menu_get_menus()
will still occur if the core Menu module is disabledI guess you would need to do it like this
Comment #12
Crossfeed CreditAttribution: Crossfeed commentedIn my case, I don't get this error when I disable menu.module and use the (patched 7.x-5.x) Zen (Starterkit) on a clean d7 installation
Comment #13
Crossfeed CreditAttribution: Crossfeed commenteddisregard, tried some times, now I get it to. I will try to roll a patch for this
Comment #14
Crossfeed CreditAttribution: Crossfeed commentedCode above wrapped in a patch
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedCan someone tell me if this patch is to be applied to the template.php of your zen theme? That's not working for me.
Comment #16
JohnAlbinThe if statement in the page.tpl is unnecessary if we ensure that $secondary_menu_heading gets a value in zen_preprocess_page().
Also, the current patch doesn't quite work if the menu module is disabled while the secondary menu is enabled. The heading for the secondary menu is empty instead of containing the menu's title.
Here's the patch I committed.
Thanks for all your help, everyone! You're in the CHANGELOG now.
Fixed. http://drupalcode.org/project/zen.git/commit/9d330c3
Comment #18
UksusoFF CreditAttribution: UksusoFF commentedSame trouble:
Notice: Undefined index: menu-afisha in zen_preprocess_page() (line 257 of .../sites/all/themes/zen/template.php).
Comment #19
UksusoFF CreditAttribution: UksusoFF commentedComment #20
JohnAlbinI've added an isset(). Fixed!