4 replies [Last post]
himagarwal's picture
Offline
Joined: 06/24/2008
Juice: 295
Was this information Helpful?

I have multiple categories assigned to my catalog items, but my breadcrumb shows all of the categories. How can I get it just to show the one with the most important weight? My pathauto does this just fine.

eoneillPPH's picture
Offline
Joined: 12/22/2008
Juice: 55
Re: Breadcrumb shows all of the categories?

I've been messing with this too. In our case (Classified Ads), the 'product' (ad package) can be used in many 'categories' (classifications). Since I only care when looking at the product, I manipulated the breadcrumb in a form_alter in my custom module (just for add_to_cart form), and it worked great... on local machine and development server, but NOT on the live site. Anyway, the code wasn't too hard. We start with the classification (category) which we get from the referring page, then look up the parents and build the links for the breadcrumb:

// our referrer ends with: /122/automobiles
$referrer = referer_uri();
$cat = array_pop($referrer);
$catid = array_pop($referrer);
$parents = array_reverse(taxonomy_get_parents_all($catid)); // an object
foreach($parents as $parent) {
$links[] = l(check_plain($parent->name), "catalog/".$parent->tid."/".$parent->name);
}
drupal_set_breadcrumb($links);

There were issues with backing up and such, so I actually ended up using a session variable to hold on to the catid. And then there's "why is ubercart overriding the breadcrumb I set ONLY on our live site?!" -- my module's weight was set to be the highest in the system table... Anyway, perhaps other folks' installations would not have that problem. We're still on 5.x-1.3.

Still haven't fixed when the category name has a '&' in it...

Does that help anybody?
--eon--

eoneillPPH's picture
Offline
Joined: 12/22/2008
Juice: 55
Re: Re: Breadcrumb shows all of the categories?

Upgraded to Ubercart 1.7, and still this breadcrumb plan works on a local and a dev server but not on live (where we still get the whole list of every taxonomy term the node is associated with). Wish someone had an inkling as to how this could be. It's the very last thing we'd like to fix on the whole store.

eoneillPPH's picture
Offline
Joined: 12/22/2008
Juice: 55
Re: Re: Re: Breadcrumb shows all of the categories?

Finally decided to fix this with a hack (which I hate to do):

In uc_catalog_nodeapi function, added
&& (isset($node->model) && strpos($node->model,'[my-product-group]')===false)
to the end of the 'if $a4 == true' condition. (Probably didn't really need to test for existence of $node->model...)

This stops catalog module from overriding the special breadcrumb set in my module's hook_form function.

It's still only our 'production' setup that needs this hack, for mysterious reasons.

eoneillPPH's picture
Offline
Joined: 12/22/2008
Juice: 55
Minor change: $links[] =

Minor change:

$links[] = l($parent->name, "catalog/".$parent->tid."/".$parent->name);

Should not have 'check_plain' on the $parent->name. Messes up when a category has '&' in it.