Revision history for WikiBreadcrumb


Revision [23076]

Last edited on 2016-05-20 07:38:45 by RolandStens [Replaces old-style internal links with new pipe-split links.]
Additions:
~& You can see this in operation [[http://stens.ca/kb | here]] RolandStens
Deletions:
~& You can see this in operation [[http://stens.ca/kb here]] RolandStens


Revision [18756]

Edited on 2008-01-28 00:12:35 by RolandStens [Modified links pointing to docs server]

No Differences

Revision [13105]

Edited on 2006-02-07 15:22:53 by RolandStens [Added demo site link]
Additions:
~& Updated the code so now it behaves a bit better and incorporates Ian's comment below.
~& You can see this in operation [[http://stens.ca/kb here]] RolandStens
Deletions:
~& Updated the code so now it behaves a bit better and incorporates Ian's comment below. RolandStens


Revision [13025]

Edited on 2006-01-31 17:43:27 by RolandStens [Added demo site link]
Additions:
~& Updated the code so now it behaves a bit better and incorporates Ian's comment below. RolandStens
<?php
// WikiTrails code V2.1 based on copyrighted code by G. M. Bowen & Andrew Somerville, 2005.
$crumbs=Array();
# Just get the PageTage, no use in doing that more times than 1
$PageTag=$this->GetPageTag();
$crumbs[0]=$PageTag;

# Test for the maximum amount of crumbs and if the last pagetag is not
# the same as the last stored tag. If it is a duplicate we'll get rid of it later.
if (count($crumbs) >= MAX_CRUMBS and $PageTag != $crumbs[MAX_CRUMBS - 1])
$crumbs[MAX_CRUMBS - 1]= $PageTag;
$crumbs[count($crumbs)]= $PageTag;
# Get rid of duplicates, but only if they are in subsequent array locations.
$count=1;
$temp = Array();
$target= Array();
# Only do this, if you have 3 or more entries in the array
if (count($crumbs) > 2) {
while ($count <= (count($crumbs) - 1))
{
$temp[$count - 1] = $crumbs[$count - 1];
$temp[$count] = $crumbs[$count];
$temp = array_unique($temp);
$target= $target + $temp;
$temp = "";
$count++;
$crumbs = $target;
else {
$crumbs = array_unique($crumbs);
}
echo "<b>Trail: </b>".$this->format($page_trail)."<hr /><br />";
?>
Deletions:
// WikiTrails code V2 based on copyrighted code by G. M. Bowen & Andrew Somerville, 2005.
$crumbs= Array();
$crumbs[0]= $this->GetPageTag();
# Test for the maximum amount of crumbs
if (count($crumbs) >= MAX_CRUMBS)
$crumbs[MAX_CRUMBS - 1]= $this->GetPageTag();
$crumbs[count($crumbs)]= $this->GetPageTag();


Revision [13011]

Edited on 2006-01-30 09:37:48 by IanHayhurst [spelling, & code amendment]
Additions:
~& which feels psychological correct (if not strictly accurate) //IanHayhurst//
Deletions:
~& which feels psycologicaly correct (if not strictly accurate) //IanHayhurst//


Revision [13003]

Edited on 2006-01-30 06:56:39 by IanHayhurst [spelling, & code amendment]
Additions:

~& After implementing this one of my installations I felt that populating this with four copies of the same page when editing was less useful. I made a modification to only add the new page if it was different from the previous one,
~& after the line:- ## $crumbs=$_SESSION['breadcrumbs'];##
~& add %%(php)
#only add breadcrumb if new page is different
if ($crumbs[count($crumbs)-1] != $this->GetPageTag() ) {
#to enclose the if / else clause following it
}
%%
~&
~& which feels psycologicaly correct (if not strictly accurate) //IanHayhurst//
Deletions:
{
$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()." ";


Revision [12962]

Edited on 2006-01-24 21:04:15 by RolandStens [spelling, & code amendment]
Additions:
Added by RolandStens
I have created a version that uses the $_SESSION variable, this makes it a bit more usable since it is not dependent on a user being logged in or not.
My persistance in calling this bread crumbs is hopefully no cause for major discussion. I hope people find this useful.
// WikiTrails code V2 based on copyrighted code by G. M. Bowen & Andrew Somerville, 2005.
// Version 2 stores the crumbs in the $_SESSION variable. This makes this feature usable for all users.
// Originally Prepared for a SSHRC funded research project extended by Roland Stens, 2006. Licensed under GPL.
# Define the maximum breadcrumbs shown.
define("MAX_CRUMBS", 5);
$crumbs= Array();
# Find out if the breadcrumbs were already stored.
if (!isset($_SESSION['breadcrumbs'])) {
# Not stored yet, so set the current page name in the crumbs array.
$crumbs[0]= $this->GetPageTag();
} else {
# The crumbs are already stored, so get them and put them in the crumbs array.
$crumbs=$_SESSION['breadcrumbs'];
# Test for the maximum amount of crumbs
if (count($crumbs) >= MAX_CRUMBS)
{
# Drop the first element in the crumbs array.
array_shift($crumbs);
# Add the new page name to the last position in the array.
$crumbs[MAX_CRUMBS - 1]= $this->GetPageTag();
}
else
{
# Not at the maximum yet, then just add to page to the end of the array.
$crumbs[count($crumbs)]= $this->GetPageTag();
}
# Save the breadcrumbs.
$_SESSION['breadcrumbs'] = $crumbs;
foreach ($crumbs as $this_crumb) {
$page_trail .= $separator."[[".$this_crumb."]]";
# Print the trail.
//FINISH breadcrumb code
%%


Revision [9952]

Edited on 2005-07-13 20:28:02 by NilsLindenberg [added heading]
Additions:
=====Simple History trail for wikka=====


Revision [9139]

Edited on 2005-06-12 03:10:26 by GmBowen [minor code update & rename to WikiTrails]
Additions:
// 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
Deletions:
// WikiTrails code V1.1 copyright by G. M. Bowen & Andrew Somerville, 2005.


Revision [9138]

Edited on 2005-06-12 03:08:35 by GmBowen [minor code update & rename to WikiTrails]
Additions:
The following code is a simple history trails feature (JavaWoman informed me that "breadcrumbs" are strictly for heirarchical systems & since wiki's are "flat" calling it a "breadcrumb" feature is inappropriate) that can be added to the header.php code to provide a linear history of the last few previously visited pages in the wiki. It only requires a single field added to the users database (add a field called "recentpages" set as type TINYTEXT and set it so it can be null (which is the default)) and it seems to work like a charm. I was inspired by the trail feature at coocoo wakka, but wrote this from scratch.
// WikiTrails code V1.1 copyright by G. M. Bowen & Andrew Somerville, 2005.
$page_trail .= $separator."[[".$this_pagename."]]";
Deletions:
The following code is a simple breadcrumb feature that can be added to the header.php code to provide a linear history of the last few previously visited pages in the wiki. It only requires a single field added to the users database (add a field called "recentpages" set as type TINYTEXT and set it so it can be null (which is the default)) and it seems to work like a charm. I was inspired by the breadcrumb trail feature at coocoo wakka, but wrote this from scratch.
// Breadcrumb code V1.1 copyright by G. M. Bowen & Andrew Somerville, 2005.
$page_trail .= $separator.$this_pagename;


Revision [8300]

Edited on 2005-05-18 18:49:18 by GmBowen [breadcrumb code update to improve functionality]
Additions:
CategoryUserContributions
Deletions:
CategoryUserContributions


Revision [8299]

Edited on 2005-05-18 18:48:46 by GmBowen [breadcrumb code update to improve functionality]
Additions:
// Breadcrumb code V1.1 copyright by G. M. Bowen & Andrew Somerville, 2005.
// Prepared for a SSHRC funded research project. Licensed under GPL.

$newstring = str_replace(' '.$this->GetPageTag().' ',' ',' '.trim($check['recentpages']).' ');

$newstring = trim($newstring).' '.$this->GetPageTag()." ";

if (str_word_count($newstring) > 6) {
$newstring = trim(strstr($newstring, " "));
}
$newstring .= " ";

// Add trails to printout
######
# 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%%
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.
Deletions:
// Breadcrumb code V1.0b copyright by GMBowen, 2005. Prepared for a SSHRC funded research project. Licensed under GPL.
$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)." ";
$newphrase = str_replace(" ", "-->", trim($recent[recentpages]));
echo "<br /><small><b>Trail:</b> ".$this->format($newphrase)."</small>";
%%
Version V1.0b adds code so that users not logged in, or those not registeres, don't see the caption "Trail:"


Revision [8035]

Edited on 2005-05-12 04:43:01 by GmBowen [minor update of breadcrumb code]
Additions:
The following code is a simple breadcrumb feature that can be added to the header.php code to provide a linear history of the last few previously visited pages in the wiki. It only requires a single field added to the users database (add a field called "recentpages" set as type TINYTEXT and set it so it can be null (which is the default)) and it seems to work like a charm. I was inspired by the breadcrumb trail feature at coocoo wakka, but wrote this from scratch.
// Breadcrumb code V1.0b copyright by GMBowen, 2005. Prepared for a SSHRC funded research project. Licensed under GPL.
if ($user = $this->GetUser())
{
$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>";
Version V1.0b adds code so that users not logged in, or those not registeres, don't see the caption "Trail:"
----
CategoryUserContributions
Deletions:
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.
// Breadcrumb code V1.0 copyright by GMBowen, 2005. Prepared for a SSHRC funded research project. Licensed under GPL.
$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>";


Revision [8002]

The oldest known version of this page was created on 2005-05-11 07:25:13 by GmBowen [minor update of breadcrumb code]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki