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!
This sounds like an execution order problem. Looking at the
menu_breadcrumbmodule, it does it’s manipulation onhook_init, whereas the views module makes its call todrupal_set_titlein the execute method of theviews_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’ moduleshook_initwill get called after thehook_initof a lighter module, but still before e.g. thehook_nodeapiof 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_titlecall of views got moved in later versions, but I doubt that, as I remember facing exactly this problem about a year ago. Maybe themenu_breadcrumbmodule changed?However, I ‘solved’ this back then by moving the breadcrumb manipulation from
hook_inittosomemodule_preprocess_page(), adjusting$variables['breadcrumb']in there directly instead of callingdrupal_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_renderand check if the title is already set there.