You are here

function tvi_get_breadcrumb in Taxonomy Views Integrator 6

Same name and namespace in other branches
  1. 7 tvi.module \tvi_get_breadcrumb()

Gets the taxonomy page breadcrumb links.

This is based off of the code for [ $views->get_breadcrumb() ].

We needed a few modifications and the ability to use views by default, but allow for theme overrides of the breadcrumb trail for this module.

We also filter out links to the current override display page, so that we do not get duplicate links, when the view path matches the current taxonomy override display path.

This also allows us to have view hierarchy in our breadcrumb, instead of the typical taxonomy breadcrumb that starts with Home, then lists the terms.

So for example, we might have something like this:

Home >> Vocab >> Parent term >> This term

1 call to tvi_get_breadcrumb()
theme_tvi_breadcrumb in ./tvi.module
Returns the taxonomy page breadcrumb (for active view overrides).

File

./tvi.module, line 424
Enables use of views for taxonomy pages.

Code

function tvi_get_breadcrumb($term, $view) {
  $breadcrumb = array();
  if (!empty($view->build_info['breadcrumb'])) {
    $curr_path = $view
      ->get_url(array(
      $term->tid,
    ));
    $base = TRUE;
    foreach ($view->build_info['breadcrumb'] as $path => $title) {

      // Check to see if the frontpage is in the breadcrumb trail; if it
      // is, we'll remove that from the actual breadcrumb later.
      if ($path == variable_get('site_frontpage', 'node')) {
        $base = FALSE;
        $title = t('Home');
      }
      if ($title && $path != $curr_path) {
        $breadcrumb[] = l($title, $path, array(
          'html' => true,
        ));
      }
    }
    if ($base) {
      $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb);
    }
  }
  return $breadcrumb;
}