GetHierarchyManager(); $thispage = $gCms->variables['content_id']; $trail = ""; //$inc_id_count = 0; #Check if user has specified a delimiter, otherwise use default if (isset($params['delimiter'])) { $delimiter = $params['delimiter']; } else { $delimiter = ">>"; } #Check if user has requested an initial delimiter if (isset($params['initial'])) { if ($params['initial'] == "1") { $trail .= $delimiter . " "; } } #Check if user has requested a start_level if (!isset($params['start_level'])) { $params['start_level'] = 0; } #Check if user has requested an incremental class id if (!isset($params['inc_classid'])) { $params['inc_classid'] = false; } $root='##ROOT_NODE##'; #Check if user has requested the list to start with a specific page if (isset($params['root'])) { $root = $params['root']; } $root_url=''; #Check if user has requested to overrided the root URL if (isset($params['root_url'])) { $root_url = $params['root_url']; } $endNode = $manager->sureGetNodeById($thispage); # build path if (isset($endNode)) { $content = $endNode->getContent(); $path=array($endNode); $currentNode = $endNode->getParentNode(); while (isset($currentNode) && $currentNode->getLevel() >= $params['start_level']) { $content = $currentNode->getContent(); if (isset($content)) { //Add current node to the path and then check to see if //current node is the set root //as long as it's not hidden if( $content->ShowInMenu() && $content->Active() ) { $path[] = $currentNode; } if (strtolower($content->Alias())!=strtolower($root)) { //Get the parent node and loop $currentNode = $currentNode->getParentNode(); } else { //No need to get the parent node -- we're the set root already break; } } else { //There are more serious problems here, dump out while we can break; } } if ($root!='##ROOT_NODE##') { // check if the last added is root. if not, add it $currentNode = $manager->sureGetNodeByAlias($root); if (isset($currentNode)) { $top_alias = '##garbage##'; if( count($path) ) $top_alias = $path[count($path)-1]->get_tag('alias'); if( strtolower($top_alias) != strtolower($root) ) { $content = $currentNode->getContent(); if( is_object($content) && $content->Active() && $content->ShowInMenu() ) { $path[] = $currentNode; } } } } $classid=isset($params['classid'])?(' class="' . $params['classid']):''; $currentclassid=isset($params['currentclassid'])?(' class="' . $params['currentclassid'] . '"'):''; // now create the trail (by iterating through the path we built, backwards) for ($i=count($path)-1;$i>=0;$i--) { $node = $path[$i]; if (isset($node)) { $onecontent = $node->getContent(); if ($onecontent->Id() != $thispage && $onecontent->Type() != 'seperator') { if (($onecontent->getURL() != "") && ($onecontent->Type() != 'sectionheader')) { if ($onecontent->DefaultContent() && false == empty($root_url)) { $trail .= 'getURL() . '"'; } $trail .= $classid; if (isset($params['classid'])){ if ($params['inc_classid']){ //$trail .= count($path) - $i; $trail .= $i; } $trail .= '"'; } $trail .= '>'; $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); $trail .= ''; } else { $trail .= ""; $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); $trail .= ''; $trail .= ' '; } $trail .= $delimiter . ''; } else { if (isset($params['currentclassid'])) { $trail .= ""; } else { $trail .= ''; } $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); if (isset($params['currentclassid'])) { $trail .= ''; } else { $trail .= ''; } } } } } if (isset($params['starttext']) && $params['starttext'] != '') { $trail = $params['starttext'] . ': ' . $trail; } if( isset($params['assign_count']) ){ $smarty->assign(trim($params['assign_count']),count($path)); } if( isset($params['assign']) ){ $smarty->assign(trim($params['assign']),$trail); return; } if( isset($params['assign_count']) ){ $smarty->assign(trim($params['assign_count']),count($path)); } return $trail; } function smarty_cms_help_function_jmbreadcrumbs() { echo ('
Prints a breadcrumbs trail.
This is a modded version of the original breadcrumbs tag with additional functionality. It allows defining a starting level as the menu tag. Additionally, there is an option to render the class with increments for each block: <... class="breadcrumbs1">, <... class="breadcrumbs2">, ..., <... class="breadcrumbsn"><span...>... and so on.
Just insert the tag into your template/page like: {jmbreadcrumbs}
Another example: {jmbreadcrumbs classid="breadcrumbs" inc_classid="true" start_level=1 starttext="You are here" root="Home" delimiter="" assign_count="jmbc_inc_id_count"}
The number of iteractions can be found in a smarty variable: $jmbc_inc_id_count
This would allow you to code your css with something like this:
[[if isset($jmbc_inc_id_count)]] /* assign starting values */ [[assign var=\'Grad_r\' value=80]] [[assign var=\'Grad_g\' value=90]] [[assign var=\'Grad_b\' value=85]] /* assign step value */ [[assign var=\'c_step\' value=-5]] [[section name=jmbc_id start=1 loop=$jmbc_inc_id_count]]
.breadcrumbs[[$jmbc_inc_id_count-$smarty.section.jmbc_id.index]]{
background-color: rgb([[$Grad_r]]%,[[$Grad_g]]%,[[$Grad_b]]%);}
[[assign var=\'Grad_r\' value=$Grad_r+$smarty.section.jmbc_id.index*$c_step]] [[assign var=\'Grad_g\' value=$Grad_g+$smarty.section.jmbc_id.index*$c_step]] [[assign var=\'Grad_b\' value=$Grad_b+$smarty.section.jmbc_id.index*$c_step]] [[/section]] .lastitem{
background-color: rgb([[$Grad_r]]%,[[$Grad_g]]%,[[$Grad_b]]%);} [[/if]] div.jm_breadcrumb{background-color:#cce6d9;}
There are, probably, better ways to code this but it works... :)
Anyway, this is only an idea... other crazy things can be done.
Also meant to be used with Babel multi language solution, by giving a start_level parameter which should be set to 1 to hide the odd link at the beginning of the breadcrumbs.
Author of this MOD: Jo Morg
Original Breadcrumbs Tag Author: Marcus Deglos <md@zioncore.com>
Based on Original Breadcrumbs Tag Version: 1.7
Version: 1.0
Moded out of need, it\'s just a share for anyone interested.
Change History: