Using "Alias" with {BREADCRUMB}

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Using "Alias" with {BREADCRUMB}

Post by pixelpeter »

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 :evil: :twisted:

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;
}
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 :lol: :twisted:
I told you before: It's dirty :twisted: :twisted:
cmslover
Posts: 86
Joined: Wed 18. Feb 2004, 16:17
Location: USA, Georgia, Atlanta
Contact:

Post by cmslover »

Wow! Pixelpeter, you are my HERO!!!! I have to keep an eye on all your post from now on :P
Stephan
Posts: 17
Joined: Sat 17. Apr 2004, 01:38
Contact:

Post by Stephan »

I just patched up everything to the latest builds... and now this mode is showing:

.html


For the home in the breadcrumb, when before it was 0.html
Post Reply