/ Published in: PHP
customized breadcrumbnavigation for PHPWCMS.
Gives more control over styling and display.
{MYBREADCRUMB:n}
Gives more control over styling and display.
{MYBREADCRUMB:n}
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function mybreadcrumb ($start_id, &$struct_array, $end_id, $spacer=' > ') { //builds the breadcrumb menu based on given values //$link_to = the page on which the breadcrum part links //$root_name = name of the breadcrumb part if empty/false/0 $start_id //$spacer = how should breadcrumb parts be divided $act_id = $start_id; //store actual ID for later comparing $breadcrumb = ''; while ($start_id) { //get the breadcrumb path starting with given start_id if($end_id && $start_id == $end_id ) break; $data[$start_id] = $struct_array[$start_id]["acat_name"]; $start_id = $struct_array[$start_id]["acat_struct"]; } $data[$start_id] = $struct_array[$start_id]["acat_name"]; //print_r($crumbs_part); $i=1; foreach($crumbs_part as $key => $value) { $alias = ''; if($struct_array[$key]["acat_hidden"] != 1) { // check if the structure should be unvisible when active if ($act_id != end_id) { if($breadcrumb) $breadcrumb .= $spacer; if(!$struct_array[$key]["acat_redirect"]) { $breadcrumb .= '<a class="breadcrumb_level_'.$i.' '.$active.'" href="index.php?'; $alias = $struct_array[$key]["acat_alias"]; $breadcrumb .= ($alias) ? html_specialchars($alias) : 'id='.$key.',0,0,1,0,0'; $breadcrumb .= '">'; } else { $redirect = get_redirect_link($struct_array[$key]["acat_redirect"], ' ', ''); $breadcrumb .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>'; } $breadcrumb .= html_specialchars($crumbs_part[$key]).'</a>'; } else { if($breadcrumb) $breadcrumb .= $spacer; $breadcrumb .= html_specialchars($crumbs_part[$key]); } $i++; } } } return $breadcrumb; } //breadcrumb replacement $replace = '@mybreadcrumb($GLOBALS["content"]["cat_id"], $GLOBALS["content"]["struct"], $1, $template_default["breadcrumb_spacer"]);'; } ?>