Community Documentation

Breadcrumb trail fix for taxonomy/term overrides

Last updated April 30, 2009. Created by incrn8 on April 30, 2009.
Log in to edit this page.

When using a View to override taxonomy/term pages, the breadcrumb trail goes missing - only the Home page link remains. By adding the following code (excluding the php tags, of course) to the Argument Handling Code section of your View, the breadcrumb trail is brought back to life:

<?php
$current
= taxonomy_get_term($args[0]);
$breadcrumbs = array(array('path' => $_GET['q'], 'title' => $current->name));
while (
$parents = taxonomy_get_parents($current->tid)) {
 
$current = array_shift($parents);
 
$breadcrumbs[] = array('path' => 'taxonomy/term/'. $current->tid, 'title' => $current->name);
}
$breadcrumbs = array_reverse($breadcrumbs);
menu_set_location($breadcrumbs);
?>

This was taken from a discussion here: http://drupal.org/node/114548#comment-912789. Several other solutions are also provided there, but this one seemed to be the cleanest solution.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 5.x
Audience
Developers and coders, Site administrators

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here