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') {

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

Members fund testing for the Drupal project. Drupal Association Learn more


David_Rothstein’s picture

Title: Extra unnecessary breadcrumb on search results pages » Extra unnecessary breadcrumb on search results pages (allow themes to modify the breadcrumb settings dynamically)
Version: 7.x-3.1 » 7.x-5.x-dev
4.01 KB

This 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.

JohnAlbin’s picture

Status: Needs review » Postponed (maintainer needs more info)

You can toggle the title being added to the end of the breadcrumb with theme_get_setting('zen_breadcrumb_title')

JohnAlbin’s picture

Version: 7.x-5.x-dev » 7.x-6.x-dev
Status: Postponed (maintainer needs more info) » Needs review

Been 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.

David_Rothstein’s picture

Here'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 :(

David_Rothstein’s picture

Actually 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.

  • JohnAlbin committed 6cffd9f on 7.x-6.x
    Issue #1500346 by David_Rothstein, wiifm, JohnAlbin: Allow themes to...
  • JohnAlbin committed 9906d05 on 7.x-6.x authored by David_Rothstein
    Issue #1500346 by David_Rothstein, wiifm: Allow themes to modify the...
JohnAlbin’s picture

Status: Needs review » Fixed

Thanks for starting this! I've done additional refactoring to make the theme function as simple as possible.

Status: Fixed » Closed (fixed)

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