Revision [8002]

This is an old revision of WikiBreadcrumb made by GmBowen on 2005-05-11 07:25:13.


The following code is a simple breadcrumb feature that can be added to the header.php code. It only requires a single field added to the users database (add a field called "recentpages" set as type TINYTEXT and setting it so it can be null (which is the default)) and seems to work like a charm. I was inspired by the breadcrumb trail feature at coocoo wakka, but wrote this from scratch.

add the following code to your header.php file near the bottom (immediately before the last "?>").
// Breadcrumb code V1.0 copyright by GMBowen, 2005. Prepared for a SSHRC funded research project. Licensed under GPL.
// Please keep attributions if distributing code.  
$username = $this->GetUserName();
$check = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
$check2 = strpos($check[recentpages], $this->GetPageTag());
$PgNmLength = strlen($this->GetPageTag()." ");
if ($check2 === false) {
$newstring = $check[recentpages].$this->GetPageTag()." ";
} else {
$newstring = substr_replace($check[recentpages], "", $check2, (strlen($this->GetPageTag())+1) );
$newstring = $newstring.$this->GetPageTag()." ";
if (str_word_count($newstring) > 6) {$newstring = strstr($newstring, " ");}
$newstring = trim($newstring)." ";
$this->query("UPDATE ".$this->config['table_prefix']."users SET recentpages = '$newstring' WHERE name='$username' ");  
$recent = $this->LoadSingle("SELECT recentpages FROM ".$this->config["table_prefix"]."users WHERE name='".$username."'");
$newphrase = str_replace(" ", "-->", trim($recent[recentpages]));
echo "<br /><small><b>Trail:</b> ".$this->format($newphrase)."</small>";

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.
There are 22 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki