Question

I have a page where nodes are categorized using a base taxonomy (let's say "species" -> animal -> mammal -> ape).

  1. I want to override taxonomy pages with panels
  2. I also want to make sure all nodes get a nice breadcrumb based on the default taxonomy

I have solved #1 and #2 successfully separately, but cannot get them to play together.

For #1 the best solution I have found is activating "Taxonomy term template" in /admin/build/pages). An excellent guide can be found at http://drupaleasy.com/blogs/ultimike/2010/10/taxonomy-term-pages-steroids-using-panels-views

For #2 both the Custom Breadcrumbs module (with the Custom Taxonomy Breadcrumb sub module) and the Taxonomy Breadcrumbs. Unfortunately both methods hijack the same hook used by #1 and in doing so disables #1.

How can I achieve both goals simultaniously? Thanks a lot!

Was it helpful?

Solution

For #2, you can use Custom Breadcrumbs. I'm not sure about version 6.x-1.x, but I can confirm that 6.x-2.0 works fine. What you need to do is to:

  • enable both sub-modules Custom Breadcrumbs for Taxonomy and Custom Breadcrumbs for Panels
  • set things up at Custom Breadcrumbs Configuration page
  • make the weight of the Custom Breadcrumbs for Panels the highest, at the bottom of the configuration page (to override Custom Breadcrumbs for Taxonomy which doesn't get along with panels by itself)

However, the custom breadcrumb is built after the panels, so you can't actually use it in the panel. But you can print it in page.tpl.php, outside the panel.

EDIT:

Seems like Custom Breadcrumbs for Panels had nothing to do with it :)

It just displayed a very misleading text on the config page ("Use taxonomy breadcrumbs for panels"). After some more research, it turned out that it works when panels had a smaller weight then custom_breadcrumbs_taxonomy (see table system in the database).

If you really want to display the breadcrumbs in panels, you can do that using this (hack-ish) method:

  • configure taxonomy breadcrumbs
  • ensure the weights are good in the system table, as explained
  • add the breadcrumb in your page panel
  • add a preprocess function that replace the breadcrumbs in panels with the final breadcrumbs, built by custom_breadcrumbs_taxonomy, like:

(note: my panel is of type page, it's in the content section)

function abn_preprocess_page(&$vars) {
  $old_breadcrumb = strstr( strstr($vars['content'],'<div class="breadcrumb">'), '</div>', true);
  if ($old_breadcrumb) {
    $old_breadcrumb .= '</div>';
    $vars['content'] = str_replace($old_breadcrumb, $vars['breadcrumb'], $vars['content']);
  }  
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top