I have a jeans product setup in one vocab under two areas as follows:

boy>>Bottoms>>Pants
boy>>Denim

The breadcrumbs show up as

Home → Catalog → Boy → Bottoms → Pants → Denim

Is this a bug or config issue?

I need the bread crumb to represent how the user got to the product.... they would either have clicked through boy>>Bottoms>>Pants Or boy>>Denim

Thoughts?

Comments

razorback’s picture

no else has seen this before?

razorback’s picture

This is driving me nuts!

WorldFallz’s picture

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.

razorback’s picture

thanks

myregistration’s picture

I'm dealing with the same issue. For a description see Scenerio at http://drupal.org/node/806784

It doesn't seem like it's Breadcrumb module is at fault because if I edit a product and select a Catalog term that resides under a single parent and submit it still selects the term for each parent, it won't allow me to select only one, which I suppose is because the one term shared by all parents. So I feel it's how they record the hierarchial relationships that make the difference.

Is this proper behavior? Can a term for a product be selected under only one of the term's parents?

atontimes’s picture

Please tell me who has solved this problem, how did you do it? I have same problem

sumaiyajaved’s picture

Use the following in your template.php
For more info click here

function phptemplate_breadcrumb($breadcrumb) {
$uri_request_id = $_SERVER['REQUEST_URI'];
$urlexplode = explode("?", $uri_request_id);
$url = explode("/",$urlexplode[0]);
$args = count($url);

$output = " home";
$path = '';
$replace = array('_','-','+','%20');

// If there is more than one directory or page after home print it
if(isset($url[1]) && $args > 1){
for($x = 1; $x < $args; $x++) {
$text = htmlspecialchars(str_replace($replace,' ',$url[$x]));
if($x < ($args-1)) {
$path .= '/' . urlencode($url[$x]);
$output .= " > " . $text . "";
} else {
$output .= " > " . $text;
}
}
}
return '' . $output . '';

}

Regards,

Sumaiya Javed
Web Developer
www.sumaiyajaved.com
www.phpjavascript.com

Andrew211’s picture

Exploding $_SERVER['REQUEST_URI'] isn't going to work mate.

Imagine if the path is node/232, and the user got there via taxonomy/term/22

Your breadcrumb will look like home >> node >> 232

Andrew211’s picture

I must say I'm a little surprised that this is still an issue in Drupal, one would have well and truly thought that by now breadcrumbs would follow the users navigation and not just default to a single path to a product that exists in multiple categories, anyway here's a fix, it's no work of art however it does seem to work.

Just put this at the top of your theme_breadcrumb

<?php
function mytheme_breadcrumb($vars) {
 
   
//if the same product display (or any node) had the multiple taxonomy terms, the breadcrumb was not displaying as expected. Only one path seemed to be available to each node.
    //Setting session variables below to store breadcrumb values according to user navigation which will be displayed on nodes (of type product)
   
if(isset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB'])){ //previous page was taxonomy (category)       
        //check if this page is a product
       
if(arg(0) == 'node'){
           
$node = node_load(arg(1));
            if(
$node->type == 'product'){
               
//the current page is a product, the previous page was a category, so setting the breadcrumb to be the same as the last page
               
$vars = $_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB'];
            }
            else{
               
//unset the bredcrumb session variable here, we don't need it the whole session, here we are on a page that is not a product display or taxonomy page so it's not needed
               
unset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']);
            }
        }
    }
   
    if(
arg(0) == 'taxonomy' && arg(1) == 'term'){
       
       
//on a taxonomy page so assigning the breadcrumb to a session variable to it can be rendered based on user navigation when
        //we reach the product display
       
       
$parts = count($vars['breadcrumb']);
       
$current_path = '<a href="'. request_uri() .'">' . drupal_get_title() . '</a>';
       
$bc = $vars;
       
$bc['breadcrumb'][$parts] = $current_path;
       
$_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']  = $bc;
    }
    else{
       
//not unsetting the session var because it would stuff the breadcrumb if the page was refreshed or a form was submitted, etc.
        //unset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']);
   
}

   
     
/** now add your normal theme_breadcrumb code here **/


}
?>
konordo’s picture

I can confirm that the above works just fine. Here's the full function:

<?php
function mytheme_breadcrumb($vars) {
   
//if the same product display (or any node) had the multiple taxonomy terms, the breadcrumb was not displaying as expected. Only one path seemed to be available to each node.
    //Setting session variables below to store breadcrumb values according to user navigation which will be displayed on nodes (of type product)
   
if(isset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB'])){ //previous page was taxonomy (category)
        //check if this page is a product
       
if(arg(0) == 'node'){
           
$node = node_load(arg(1));
            if(
$node->type == 'ad'){
               
//the current page is a product, the previous page was a category, so setting the breadcrumb to be the same as the last page
               
$vars = $_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB'];
            }
            else{
               
//unset the bredcrumb session variable here, we don't need it the whole session, here we are on a page that is not a product display or taxonomy page so it's not needed
               
unset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']);
            }
        }
    }
    if(
arg(0) == 'taxonomy' && arg(1) == 'term'){
       
//on a taxonomy page so assigning the breadcrumb to a session variable to it can be rendered based on user navigation when
        //we reach the product display
       
$parts = count($vars['breadcrumb']);
       
$current_path = '<a href="'. request_uri() .'">' . drupal_get_title() . '</a>';
       
$bc = $vars;
       
$bc['breadcrumb'][$parts] = $current_path;
       
$_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']  = $bc;
    }
    else{
       
//not unsetting the session var because it would stuff the breadcrumb if the page was refreshed or a form was submitted, etc.
        //unset($_SESSION['PREVIOUS_PAGE_TAXONOMY_BREADCRUMB']);
   
}
 
/** now add your normal theme_breadcrumb code here **/
 
$breadcrumb = $vars['breadcrumb'];

  if (!empty(

$breadcrumb)) {
   
// Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
   
    // Optional - Adding the title of the current page to the breadcrumb.
   
$breadcrumb[] = drupal_get_title();
   
   
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

   

$output .= '<div id="breadcrumb"><nav class="breadcrumb-wrapper with-breadcrumb-label clearfix" role="navigation">' . implode(' » ', $breadcrumb) . '</nav></div>';
    return
$output;
  }     
}
?>

--------------------------------------------
Konordo Ltd
http://www.konordo.com