Wednesday, January 28, 2009

Drupal Set Taxonomy Breadcrumb Programmatic

To Set Breadcrumb to Taxonomy Programmatically.
Add this code in Template.php

function theme_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$cat = taxonomy_get_term(arg(1)) ;
if(taxonomy_get_parents($cat->tid) == array()) {
$breadcrumb[] = l($cat->name , str_replace(" ","-",(strtolower($cat->name))));
}
else {
$parent_term = taxonomy_get_parents($cat->tid);
foreach($parent_term as $key => $value){
$name = $parent_term[$key]->name;
}
$breadcrumb[] = l($name , str_replace(" ","-",(strtolower($name))));
$breadcrumb[] = l($cat->name , str_replace(" ","-",(strtolower($name))."/".str_replace(" ","-",(strtolower($cat->name)))));
}
}
}

No comments:

Post a Comment