[Pmwiki-users] BreadCrumb Trails
David Jackson
itdoctor
Sat Feb 28 10:16:28 CST 2004
I have had a go at implenmenting a breadcrumb trail & I am now at the
'tearing out hair' stage ;-)
I had a look around & found the following link:
http://php.softwarefolder.com/view.php/4325/
Cool! Uses a cookie to store previous pages, so ideal for a wiki. Most
others I have seen use the directory structure, nice, but no good for
wikizens.
'This should be easy to adapt', I stupidley thought, & came up with the
following:
<?php
function BreadCrumbTrail(){
$breadCrumbHTML = "<DIV ALIGN='right'>";
$breadCrumbHTML .= "<B>Recently Viewed:</B> ";
## The $title is the hyperlink test of a page. This must
## be different for every page in the trail.
$title = "$HTMLTitle";
$path = "$PageUrl";
$path = "<a href=$path>$title</a>";
// Code begins here....
$old_value = $HTTP_COOKIE_VARS["my_trail"];
if (strstr($old_value,$path)) {
$new_value = $old_value;
setcookie("my_trail",$new_value,time()+14400,"/","",0);
}
else {
if($old_value!=""){
$new_value = "$old_value > $path";
setcookie("my_trail",$new_value,time()+14400,"/","",0);
}else{
$new_value = "$path";
setcookie("my_trail",$new_value,time()+14400,"/","",0);
}
}
$trail = "$new_value";
$splitter = explode($path, $trail);
$trail = "$splitter[0] $title";
$breadCrumbHTML .= "$trail";
$breadCrumbHTML .= "</DIV>";
return $breadCrumbHTML;
}
$visitedTrail =& BreadCrumbTrail();
?>
Now *all* I have to do is save it, include it in my config.php and edit
the template to insert $visitedTrail where I want the trail.
But all I can see is 'Recently Viewed:' (At least I know it is being
included/called).
Is this because the variables $HTMLTitle, $PageURL are not set before
this gets called?
Or am I missing something more obvious? Like non expansion of variables?
Don't they have to be "quoted" in PHP?
--
Dave J
More information about the pmwiki-users
mailing list