client wants to put some Taxonomy term as Primary menu. The taxonomy menu module adds links to the navigation menu for taxonomy terms.
(1) Install taxonomy menu module
(2) make some setting of taxonomy menu module
now we want to change path of these term in menu. it provides some hook for ..
/**
* Implementation of hook_taxonomy_menu_path.
*
* @return array
* function name => Display Title
* a list of the path options.
*/
function ess_public_taxonomy_menu_path() {
$output = array('ess_public_menu_path_default' => t('Ess Category Search'));
return $output;
}
/**
* Callback for hook_taxonomy_menu_path
*/
function ess_public_menu_path_default($vid, $tid) {
//if tid = 0 then we are creating the vocab menu item format will be taxonomy/term/$tid+$tid+$tid....
if ($tid == 0) {
//get all of the terms for the vocab
$path = "ess_public/search_result/category/";
}
else {
$path = taxonomy_term_path(taxonomy_get_term($tid));
if (variable_get('taxonomy_menu_display_descendants_'. $vid, FALSE)) {
//Use 'all' at the end of the path
$term = taxonomy_get_term($tid);
$path = "ess_public/search_result/category/".$term->name;
if (variable_get('taxonomy_menu_end_all_'. $vid, FALSE)) {
// $path .= '/all';
$term = taxonomy_get_term($tid);
$path = "ess_public/search_result/category/".$term->name;
}
else {
//we wait to run this instead of durning the if above
//because we only wan to run it once.
$terms = taxonomy_get_tree($vid, $tid);
foreach ($terms as $term) {
$tids[] = $term->tid;
}
if ($tids) {
$end = implode(' ', $tids);
$path .= $end;
}
}
}
else
{
$term = taxonomy_get_term($tid);
$path = "ess_public/search_result/category/".$term->name;
}
}
return $path;
}