I was having trouble removing the 'title' from the end of the breadcrumb from search results (using apachesolr - but I am pretty sure standard drupal does the same) pages. Out of the box it is (upon a search for the word 'student'):
Home › Search › Site › student › Site
Using theming I was able to remove the 3rd breadcrumb 'Site', my code below in template.php:
function MYTHEME_menu_breadcrumb_alter(&$active_trail, $item) {
// we want remove the extra breadcrumbs on search pages as of the box they are
// Home › Search › Site › student › Site
// Note the extra 'Site' breadcrumbs in there
else if (arg(0) == 'search') {
foreach ($active_trail as $index => $breadcrumb) {
if (isset($breadcrumb['link_title']) && $breadcrumb['link_title'] == 'Site') {
unset($active_trail[$index]);
}
}
}
}
Now the breadcrumb looks like
Home › Search › student › Site
But I don't see a way to remove the 'title' from the end of the breadcrumb trail. It is not a breadcrumb in the traditional sense as it is added by zen_breadcrumb
, and thus my hook_menu_breadcrumb_alter() does not have access to remove it.
Attached is a patch that removes the 'title' and trailing seperator from the end of the breadcrumb trail when on search results landing pages
If there are any better ideas on doing this, let me know
Comment | File | Size | Author |
---|---|---|---|
#5 | zen-breadcrumbs-1500346-5.patch | 4.1 KB | David_Rothstein |
#4 | zen-breadcrumbs-1500346-4.patch | 4.09 KB | David_Rothstein |
#1 | zen-breadcrumbs-1500346-1.patch | 4.01 KB | David_Rothstein |
zen-remove-search-title-from-breadcrumb.patch | 539 bytes | wiifm |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedThis might be expanding the issue a bit, but I think having Zen try to deal directly with this particular search scenario may be a bit too specific.
I think the underlying issue here is that there is no good way for a particular subtheme or site to easily alter Zen's breadcrumb display on a case-by-case basis. It's possible to override zen_breadcrumb() entirely, of course, but that's a lot of code and logic for a small change. I think as a base theme, it would be a good idea for Zen to make its theme function as flexible as possible.
This patch therefore removes the hardcoded theme_get_setting() calls from zen_breadcrumb() and adds them as a variable in a preprocess function. That way, subthemes (or even modules) can easily implement preprocess/process functions of their own to modify the breadcrumb displays settings in a particular case or anything else they want to do.
Comment #2
JohnAlbinYou can toggle the title being added to the end of the breadcrumb with theme_get_setting('zen_breadcrumb_title')
Comment #3
JohnAlbinBeen thinking about this one for a while and I agree with your point. It's obvious we shouldn't be querying the database from a template file, neither should we be using theme_get_setting().
But I'm not sure changing the internals of this theme function is safe to do in 7.x-5.x branch without breaking existing sites.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedHere's a reroll (applies equally well to the latest 7.x-5.x-dev and 7.x-6.x-dev code).
Reroll wasn't actually done by me; someone else did it long ago and I found it lying around a codebase but it had never been posted to drupal.org :(
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedActually that reroll wasn't correct; one of the check_plain() calls introduced by that patch should be a filter_xss_admin() instead, in keeping with the previous code.
The other check_plain() calls might not even be necessary, although I'm leaving them in for now.
Comment #7
JohnAlbinThanks for starting this! I've done additional refactoring to make the theme function as simple as possible.