8

I'm using the core taxonomy module for blog tags but when on a tag's page can only get the breadcrumb to appear as 'Home', whereas I'd like it ideally to be 'Home > Blog > #Tag#'. I'm using custom breadcrumb module to set breadcrumbs for content types (<- doesn't allow for taxonomy breadcrumbs) and have tried using taxonomy breadcrumb module with absolutely no result, partly due to the fact that it's not a particularly configurable module. Blog tag pages (listing all the nodes under a term) seem to be generated from the core taxonomy module and not views so I can't resolve the issue in views.

If anyone could point me in the right direction I'd be grateful :)

3

This sounds like something you could do relatively easy with drupal_set_breadcrumb in a custom module.

This is most likely what custom breadcrumb module is using itself. You will have to alter the breadcrumbs after custom breadcrumb module but before they are rendered. This might be what is giving your some problems with the taxonomy breadcrumb module.

You might be able to use it if you alter it's weight in system table, depinging on how the two modules alter the breadcrumbs. My guess is that it's done with hook_init

9

This can be accomplished by overriding theme_breadcrumb() in your theme's template.php An example implementation:

function mytheme_breadcrumb($breadcrumb) {

  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
    $breadcrumb = array();
    $breadcrumb[] = l(t('Home'), '<front>');
    $breadcrumb[] = l(t('Blog'), 'path/to/blog');

    $tid = arg(2);

    if ($term = taxonomy_term_load($tid)) {
      $uri = entity_uri('taxonomy_term', $term);
      $breadcrumb[] = l($term->name, $uri['path'], $uri['options']);
    }
  }

  // resume normal operation
  if (!empty($breadcrumb)) {
  // uncomment the next line to enable current page in the breadcrumb trail
    $title = drupal_get_title();
    if (!empty($title)) {
      $breadcrumb[] = $title;
      unset($title);
    }

    return '<div class="breadcrumb">'. implode(' &gt; ', $breadcrumb) . '</div>';
  }
}
4

There is a module for that (well more than one):

Probably would choose custom breadcrumbs due to its flexibility, and ability to craft breadcrumbs for the rest of your site as well.

  • I am using custom_breadcrumbs but have no ability to customize the breadcrumbs for taxonomy terms based on content type. – KenAesthetic Jan 26 '12 at 19:29
2

I was having the same problem with taxonomies. I came across the module "Easy Breadcrumbs", which looks off of the URL construction to generate the breadcrumbs (relies on Pathauto and Clean URLs).

For example:

example.com/style/mediterranean

Home > Style > Mediterranean

I understand that in many cases this will not help, but if your breadcrumbs mimic your URL construction, then Easy Breadcrumbs should solve your problems.

1

I was using Taxonomy Display and found that drupal_set_breadcrumb() was failing on hook_init() and breadcrumb overrides were failing in other modules.

See this issue for a patch and offered solution to users of this module: breadcrumb handling makes it impossible to alter breadcrumbs for terms without parents

1

With Crumbs 7.x-2.x:

  1. Visit admin/structure/crumbs, and enable the taxonomy.* plugin wildcard, or sth more specific from the taxonomy plugin family. (it might already be enabled, but have a look to be sure)

  2. Go to admin/structure/crumbs/entity-parent/taxonomy-term, and set "blog" as the parent path for your chosen vocabulary.

  3. Visit admin/structure/crumbs, make sure that crumbs.entityParent.* (or something more specific) is enabled.

With Crumbs 7.x-1.x:

  1. Visit admin/structure/crumbs, and enable the taxonomy.* plugin wildcard, or sth more specific from the taxonomy plugin family. (it might already be enabled, but have a look to be sure)

  2. Write a custom module with a Crumbs plugin (*) that makes "blog" the parent path for "taxonomy/term/%taxonomy_term".

  3. Visit admin/structure/crumbs, enable your new plugin, and give it a priority weaker (further down) than the taxonomy.* or taxonomy.termParent.*.

(*) Writing the plugin: http://drupal.org/node/1398876
The example may be a bit overkill for this purpose, I hope you can find your way.

  • In the 7.x-2.x branch of Crumbs, instead of the custom plugin in step 2, you can specify a token pattern to set "blog" as the parent path for taxonomy term pages. – donquixote Apr 30 '13 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.