This request is related to an issue I am working on in the custom breadcrumbs issue queue #666724: views caching hides breadcrumb, and is a followup of is a followup of #721708: Use display_plugin name to identify allowed displays for custom breadcrumbs, comment #2:

Views actually has a mechanism with which you can feed it the breadcrumb, assuming your custom breadcrumb happens during the process of rendering the view. You can find out a lot by peering at $view->build_info -- in particular, there's a 'breadcrumb' area. Custom breadcrumb can put whatever it likes there and Views will happily use it, if it's appropriate for Views to place a breadcrumb. If it is not, Views will not do so.

Would that fix your problem?

I've traced through the views code and I can't find a hook where a contrib module can modify the views breadcrumb via build_info['breadcrumb']. Perhaps I've missed something? Here's what I've learned...

The build_info array is initialized after hook_views_pre_build() is called by views_plugin_display_page :: execute(). $view->build_info['breadcrumb'] is set within _build_arguments(), and then the breadcrumb is set via get_breadcrumb(). All of this happens before view->render() (which calls hook_views_pre_execute and (still later) hook_views_pre_render). So I can't find a place to modify $view->build_info['breadcrumb'] using any of the available hooks.

The hook to do this would have to occur in the build process, before get_breadcrumb(). Alternatively, I think it would be better if get_breadcrumb() could be called after the render process was complete at the end of views_plugin_display_page :: execute().

I really would like to be able insert the breadcrumb data into the views object as initially suggested. This way, even if the view is cached, the breadcrumb would be preserved along with the rendered view. Right now I can set the breadcrumb via drupal_set_breadcrumb during hook_views_pre_render(), but this won't work with a cached view. If I try this with a hook like hook_views_pre_execute() the results aren't available to help form the breadcrumb...

@merlinofchaos and/or dereine, does this make sense? Am I missing something? Any suggestions?

Thanks!

Comments

merlinofchaos’s picture

The hook to do this would have to occur in the build process, before get_breadcrumb(). Alternatively, I think it would be better if get_breadcrumb() could be called after the render process was complete at the end of views_plugin_display_page :: execute().

Conveniently...that's when ::get_breadcrumb() is actually called. What's the problem again?

merlinofchaos’s picture

Oh I see. It's called *prior* to render(). Hmm.

I think the reason for that is so that certain things could ovewrite the breadcrumb during the render process and get away with it. Doing it later than that is a bit of a problem.

If that's the case, you can just set the breadcrumb manually in hook_pre_render() I suppose.

MGN’s picture

Yes, I am currently using hook_pre_render to manually set the breadcrumb. This works great unless the view is cached. Then, the modified breadcrumb is ignored (because the hook isn't called) and the view resorts to Home (until this cache is refreshed). I am trying to find a way to fix this problem in #666724: views caching hides breadcrumb.

crea’s picture

subscribing

Letharion’s picture

Assigned: Unassigned » merlinofchaos

@merlin
This one looks like it needs the attention of a maintainer :)

merlinofchaos’s picture

Why not use hook_views_post_render() instead of hook_views_pre_render()? That gets called whether or not the rendering was cached.

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

I guess this is as answered as can be with #6, until there's more.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.