Want to make your breadcrumbs work properly when using a Views page and Menu Trails? The following worked for me.
First, the good part: in modules/menutrails/menutrails.module add the following function:
/**
* Implementation of hook_views_pre_view()
*
* This will be invoked on every view request before the view is
* themed, even if the view is cached
*/
function menutrails_views_pre_view(&$view, &$items) {
if ($view->display_handler->display->display_plugin=='page') {
drupal_set_breadcrumb(menutrails_get_breadcrumbs());
}
}
Now, if you care to read it, the boring explanation.
The way MenuTrails works is by using the so-called Node API hook. This is called (although not directly nor exclusively) by node_load() - the registered “handler” of node content. You see, Drupal has a central registry of methods dealing with accessing and displaying content. One such handler is the node handler, but it is not the only one. Have a look at the menu_router table in the Drupal database for a list. The handler is chosen based on the path of the item.
If you define a view with a page and assign it a path, it gets its very own entry in the menu_router table, pointing to views_page() as the method that handles the display of the view. Node API is completely out of the picture for, I hope, obvious reasons.
The trick then, is to have MenuTrails respond to a different kind of hook - one that is actually invoked somewhere by the Views module. Lucky for us there are several, of which I have somewhat arbitrarily picked hook_views_pre_view(), which, according to the online Drupal documentation, is “called just before a view is themed. This is called even if the query is cached.”
It turns out this works just perfectly for our cause. Right now the snippet of code is as simple as I can make it. If you have any improvements, let me know.
I hope this saves someone a ton of work. It certainly cost me that to find this out, but it was a fruitful experience.

This doesn’t work for me. I’ve got a half-dozen links in my primary links menu. One of them is /resources. My view has a path /resources/type/%. It looks like menutrails looks for items beneath each link, but I’m not sure this qualifies since it has a wildcard…
Thanks very much for suggesting this. It works nicely, although as mentioned, doesn’t work for wildcards.
This doesn’t work with views & panels arguments - is there a way yo make this work?
I have patched og to work for drupal 6 now my panels are passing arguments to the views so I have 4 groups working with 3 sets of view in the og_panel.
My primary links menu is the og home page - now the titles and more links are leading to the views page by passing the %1 arg to the view - the problem is that the menu_trail doesn’t accept the arg.
If I had a “static path” to each view page I would add it to primary links and would get this to work - thus this isn’t the case I am dealing with.
Hope you have a smart idea.
I have used your code and it works great, except one thing. In my Zen sub theme I have selected “Append the content title to the end of the breadcrumb” and would like the view title to return as a node title does in the breadcrumb, but instead the bread crumb returns as a link and with a separator at the end. I would like it to return with no separator and as text, not a link.
Thanks!
ok, I poorly described my problem. Basically menutrails_get_breadcrumbs() was retuning an array and the last item was a link to the views page I was on. I was the appending the page title to the breadcrumb using the setting on admin/build/themes/settings/my-theme. I needed to remove the link before my page title since they were essentially duplicates. I did do with the code below:
function menutrails_views_pre_view(&$view, &$items) {
if ($view->display_handler->display->display_plugin=='page') {
$trail = menutrails_get_breadcrumbs();
$deadweight = array_pop($trail);
drupal_set_breadcrumb($trail);
}
}
Thanks for your code it HOOKED ME UP!
There are a lot of equality checks in the menutrails module for link_path vs. the item href. They don’t take into account that the href is fully expanded and the link path still contains a wildcard. You can see an example of this in the menutrails_get_breadcrumbs function.