Using "Alias" with {BREADCRUMB}
Posted: Sun 7. Mar 2004, 19:31
O.K. !! This one is really a dirty hack
We need to modify the function breadcrumb in the file front.func.inc.php.
What we do: We will create our additional array wich hold the alias names parallel to the $data/$crumbs_part array identified by the same key. Really simple, really dirty
function breadcrumb starts at line: 474 Here's the completet function. You will easily find the 3 places where we inserted our $aliasNames-Array:
Yes, you're right. The link to the homepage is wrong ! It show "0.html". But this doesn't really matter, because when phpwcms doesn't find a page it automagically redirects to the homepage, well and that's where we wanna go
I told you before: It's dirty
We need to modify the function breadcrumb in the file front.func.inc.php.
What we do: We will create our additional array wich hold the alias names parallel to the $data/$crumbs_part array identified by the same key. Really simple, really dirty
function breadcrumb starts at line: 474 Here's the completet function. You will easily find the 3 places where we inserted our $aliasNames-Array:
Code: Select all
function breadcrumb ($start_id, $struct_array, $end_id, $link_to="index.php", $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
$start_id = intval($start_id);
$end_id = intval($end_id);
$act_id = $start_id; //store actual ID for later comparing
while ($start_id) { //get the breadcrumb path starting with given start_id
$data[$start_id] = $struct_array[$start_id]["acat_name"];
$aliasLink[$start_id] = $struct_array[$start_id]["acat_alias"];
$start_id = $struct_array[$start_id]["acat_struct"];
if($end_id && $start_id == $end_id) break;
}
$data[$start_id] = $struct_array[$start_id]["acat_name"];
$aliasLink[$start_id] = $struct_array[$start_id]["acat_alias"];
$crumbs_part = array_reverse($data, 1);
if(sizeof($crumbs_part)) {
$breadcrumb = "";
foreach($crumbs_part as $key => $value) {
if ($act_id != $key) {
$breadcrumb .= ($breadcrumb) ? $spacer : "";
// $breadcrumb .= "<a href=\"".$link_to."?id=".$key.",0,0,1,0,0\">";
$breadcrumb .= '<a href="'.$link_to.'?'.$aliasLink[$key].'">';
$breadcrumb .= html_specialchars($crumbs_part[$key])."</a>";
} else {
$breadcrumb .= (($breadcrumb) ? $spacer : "").html_specialchars($crumbs_part[$key]);
}
}
} else {
$breadcrumb = "";
}
return $breadcrumb;
}
I told you before: It's dirty