[pmwiki-users] $PreviousPage variable?

Martin Fick mogulguy at yahoo.com
Thu Aug 9 01:07:00 CDT 2007


--- Sivakatirswami <katir at hindu.org> wrote:
> Then, let's say I click on this from within
> Trees.Palms when PMwiki send out the 
> Main.ToDoForm page (Page B) opens, we have
> $PreviousPage available to input as a hidden
> value and it would be, in this case: 
> "Trees.Palms"

If you want to implement this with cookies or sessions
you can use the 
http://www.pmwiki.org/wiki/Cookbook/HttpVariables
recipe to implement this.  If you look at these
examples here:
http://www.theficks.name/test/HttpVariables/pmwiki.php?n=Test.Vars
you should notice that the footer at the bottom will
tell you the previously visited page on that wiki.  If
you use the 
http://www.pmwiki.org/wiki/Cookbook/AllGroupHeader
recipe you can set {$!PreviousPage} for every visited
page like this.  (:cookie PreviousPage {$FullName}:)

The disadvantage with cookies or sessions is that you
will potentially get false results under some
circumstances, such as with tabbed browsing
potentially.


Another more accurate solution also involving the
http://www.pmwiki.org/wiki/Cookbook/HttpVariables and
a customization (patch to pmwiki) similar to the one
done for the
http://www.pmwiki.org/wiki/Cookbook/DynamicWikiTrails
recipe.

You could modify pmwiki to automatically add the
current (i.e referring page as a GET value to every
single link that pmwiki creates).  Toward the end of
the LinkPage function, add this line: 

$qf .= $qf ? "&amp;":"?" . "PreviousPage=$pagename"; 

right before:
     $fmt = str_replace(array('$LinkUrl',
'$LinkText'),
             array(PageVar($tgtname,
'$PageUrl').PUE($qf), $txt), $fmt);
     return FmtPageName($fmt,$tgtname);
}


This is completly untested and is based on an older
version of pmwiki, the LinkPage function may have
changed slightly since then, but you should be able to
get the idea from this.  I hope this helps,

Good luck,

-Martin



      ____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 



More information about the pmwiki-users mailing list