Posted by longwave on February 29, 2012 at 1:12pm
18 followers
| Project: | Menu position |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Issue Summary
Discovered while trying to use Menu Position with Special Menu Items, the breadcrumb trail does not get set because Special Menu Items calls drupal_get_breadcrumb() and drupal_set_breadcrumb() in hook_init(). This causes the 'menu_set_active_trail' and 'drupal_set_breadcrumb' static caches to be initialised too early for menu_position_activate_rule() to have any effect.
The attached patch fixes this by explicitly resetting these static caches when setting breadcrumbs. This could perhaps be considered a bug in Special Menu Items, but I suspect other breadcrumb related modules may cause the same problem.
| Attachment | Size |
|---|---|
| menu_position-special_menu_items.patch | 853 bytes |
Comments
#1
thanks @longwave - exactly what i needed!
#2
@longwave, great work! I am using Menu Position with Menu Breadcrumb, and the breadcrumb wouldn't show up, but the patch made it appear. Without the title, though, even though I have 'Append page title to breadcrumb' selected in Menu Breadcrumb settings. But I have a breadcrumb and that's what counts.
#3
Thanks, this patch helps with Menu Breadcrumb. As I add the page title through the theme (Zentropy) it works perfect.
#4
Patch works, but Menu Breadcrumb cannot add page title. Can something be done about it in Menu Breadcrumb module? I also tried to edit module weights, but that does not help.
#5
Work also for panel paths like 'node/%node/article'
#6
Yup, works for me with menu breadcrumbs as well. Marking "reviewed and tested" since it seems like we've got a few folks reporting success.
#7
Patch updated to use paths relative to the module directory. Great work on this one, just what I needed.
#8
Changing modules weight has no effect because of this :
<?php/**
* Implements hook_page_delivery_callback_alter().
*
* This is the only hook that occurs after the page callback, but before
* hook_page_build (when blocks are added). We're using this hook for its
* timing, not its data.
*/
function menu_position_page_delivery_callback_alter() {
//...
}
?>
Perhaps menu_position should give a chance to other modules to alter the breadcrumb (like adding the current page title).
This could be done inside this function, by adding a drupal_alter() before setting active trail :
<?php
function menu_position_activate_rule($rule, $context, $set_breadcrumb) {
//...
drupal_alter('menu_position_active_trail', $active_trail, $context);
menu_set_active_trail($active_trail);
}
return TRUE;
}
?>
However, should menu_position prevail over all other breadcrumb related modules?
Using menu_position makes all other modules useless.
#9
The patch in #7 works fine for me. (I have no problem with the title, it's added to the bc trail)
#10
Patch in #7 works for me using Panels and solves my problem in this context.
#11
Patch in #7 works for me
Upping priority as the patch is 5 months old.
#12
+1 for RTBC (using this in production)
Please lets get #7 in.
#8: An alter hook is a nice idea.
Overriding other modules is no problem, because you can select _when_ to apply menu position rules. Want another module? Just don't use mpr on this path.
#13
+1 for #7. Work for me too
#14
The patch in #7 solved an issue of the breadcrumb not appearing in a panel. Yay!