Revision [9139]
This is an old revision of WikiBreadcrumb made by GmBowen on 2005-06-12 03:10:26.
add the following code to your header.php file near the bottom (immediately before the last "?>").
// WikiTrails code V1.1a copyright by G. M. Bowen & Andrew Somerville, 2005.
// Version1.1a has a minor code change (as suggested here) so that non-wikiname pages were linked properly
// Prepared for a SSHRC funded research project. Licensed under GPL.
// Please keep attributions if distributing code.
if ($user = $this->GetUser())
{
$username = $this->GetUserName();
$check = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
$newstring = str_replace(' '.$this->GetPageTag().' ',' ',' '.trim($check['recentpages']).' ');
$newstring = trim($newstring).' '.$this->GetPageTag()." ";
if (str_word_count($newstring) > 6) {
$newstring = trim(strstr($newstring, " "));
}
$newstring .= " ";
$this->query("UPDATE ".$this->config['table_prefix']."users SET recentpages = '$newstring' WHERE name='$username' ");
// Add trails to printout
$recent = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
######
# Section rewritten by andrew.
$page_names = Array();
# Parse string at spaces, into an array.
$this_pagename = strtok(trim($recent[recentpages]), " ");
while ($this_pagename) {
array_push($page_names,$this_pagename);
$this_pagename = strtok(" ");
}
# Get rid of duplicates.
$page_names = array_unique($page_names);
# Create the trail by walking through the array of page names.
$separator = "";
$page_trail = "";
foreach ($page_names as $this_pagename) {
$page_trail .= $separator."[[".$this_pagename."]]";
$separator = "-->";
}
# Print the trail.
echo "<br /><small><b>Trail:</b> ".$this->format($page_trail)."</small>";
#######
}
//FINISH breadcrumb code
// Version1.1a has a minor code change (as suggested here) so that non-wikiname pages were linked properly
// Prepared for a SSHRC funded research project. Licensed under GPL.
// Please keep attributions if distributing code.
if ($user = $this->GetUser())
{
$username = $this->GetUserName();
$check = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
$newstring = str_replace(' '.$this->GetPageTag().' ',' ',' '.trim($check['recentpages']).' ');
$newstring = trim($newstring).' '.$this->GetPageTag()." ";
if (str_word_count($newstring) > 6) {
$newstring = trim(strstr($newstring, " "));
}
$newstring .= " ";
$this->query("UPDATE ".$this->config['table_prefix']."users SET recentpages = '$newstring' WHERE name='$username' ");
// Add trails to printout
$recent = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
######
# Section rewritten by andrew.
$page_names = Array();
# Parse string at spaces, into an array.
$this_pagename = strtok(trim($recent[recentpages]), " ");
while ($this_pagename) {
array_push($page_names,$this_pagename);
$this_pagename = strtok(" ");
}
# Get rid of duplicates.
$page_names = array_unique($page_names);
# Create the trail by walking through the array of page names.
$separator = "";
$page_trail = "";
foreach ($page_names as $this_pagename) {
$page_trail .= $separator."[[".$this_pagename."]]";
$separator = "-->";
}
# Print the trail.
echo "<br /><small><b>Trail:</b> ".$this->format($page_trail)."</small>";
#######
}
//FINISH breadcrumb code
If you want the list of previously visited pages to be greater or lesser change the "6" value.
Hope this meets your needs folks. If you find ways of making the code more efficient (and that is certainly possible), then please feel free to update it.
Version V1.1 fixes search and replace issues. Problem was that if you were at the page AndrEw and you also had a page AndrewsPage then when you moved around sooner or later you'd get sPage. That problem is now solved.
CategoryUserContributions