views:

204

answers:

1

I have used the menu_breadcrumb module as the basis for a module that produces a breadcrumb based on the current URL path. It works great on regular nodes, but on any pages that are rendered by the Views module, the breadcrumb cannot get the title of the page. The module's call to drupal_get_title() returns an empty value.

I wouldn't be so surprised by this except that I have another Drupal site that does exactly the same thing, and it works correctly. The only difference is that this site is based on the Acquia Drupal distribution, and that it the other site where it works hasn't been updated in a while, so has older versions of both Drupal core and Views.

I read something about module weights, and tried setting the weight on my breadcrumb module to a really high value, but that didn't help.

Thanks for any ideas!

A: 

This sounds like an execution order problem. Looking at the menu_breadcrumb module, it does it's manipulation on hook_init, whereas the views module makes its call to drupal_set_title in the execute method of the views_plugin_display_page, which happens at a later stage. Manipulating the module weight does not help in cases like this, as the weights only determine the call/execution order per hook, but they do not effect the execution order of whole modules. (In other words, a 'heavier' modules hook_init will get called after the hook_init of a lighter module, but still before e.g. the hook_nodeapi of the lighter module.)

I'm a bit surprised that this works on the other site as you stated - it might be that the drupal_set_title call of views got moved in later versions, but I doubt that, as I remember facing exactly this problem about a year ago. Maybe the menu_breadcrumb module changed?

However, I 'solved' this back then by moving the breadcrumb manipulation from hook_init to somemodule_preprocess_page(), adjusting $variables['breadcrumb'] in there directly instead of calling drupal_set_breadcrumb. This is not optimal as it disables any other breadcrumb manipulation that might be happening before the page themeing, but if you know that you always want your breadcrumb, this might well be an advantage.

As an alternative, one might implement one of the views hooks in the breadcrumb manipulation module, e.g. hook_views_pre_render and check if the title is already set there.

Henrik Opel
Henrik, turns out that it does *not* work that way on the other site. I actually printed out the page title at the end of the breadcrumb block! :-\Sorry for the snipe hunt...
gravelpot

related questions