I assigned my features menu to be the secondary menu source but noticed that the links did not come through. Upon inspection of features.module I noticed the following code:
<?php
/**
* Preprocess function for features links.
*/
function features_preprocess_page(&$vars) {
if (variable_get('menu_primary_links_source', 'primary-links') == 'features') {
$vars['primary_links'] = features_menu_links();
}
if (variable_get('menu_secondary_links_source', 'secondary-links') == 'features') {
if (variable_get('menu_secondary_links_source', 'primary-links') == 'features') {
$vars['secondary_links'] = features_menu_links(1);
}
else {
$vars['secondary_links'] = features_menu_links();
}
}
}
?>
The problem is that the nested check on the primary-links source within the secondary-links block checks menu_secondary_links_source when it should be checking menu_primary_links_source like so:
<?php
/**
* Preprocess function for features links.
*/
function features_preprocess_page(&$vars) {
if (variable_get('menu_primary_links_source', 'primary-links') == 'features') {
$vars['primary_links'] = features_menu_links();
}
if (variable_get('menu_secondary_links_source', 'secondary-links') == 'features') {
if (variable_get('menu_primary_links_source', 'primary-links') == 'features') {
$vars['secondary_links'] = features_menu_links(1);
}
else {
$vars['secondary_links'] = features_menu_links();
}
}
}
?>
If this makes sense, I'll post a quick patch with my updated code.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | features_menu.patch | 570 bytes | nicks |
Comments
Comment #1
nicks commentedThis makes a lot of sense! I was having the problem where the features menu was not appearing when I set it to "secondary links", and this fixed it.
I've attached a patch, so hopefully someone will roll this into the next release of the module.
Comment #2
yhahn commentedFeatures no longer hijacks the nav links vars in preprocess_page() so this shouldn't be an issue anymore.