Summary: Trail history of the last (default=5) visited wiki pages
Version: 20060516
Prerequisites: pmwiki 2.1.5
Status: Stable
Maintainer: Americo Albuquerque
Categories: Links, WikiTrails
Users: (view? / edit)
Discussion: TraceTrail-Talk?

Questions answered by this recipe

Is it possible to have a list of the previous n pages seen before?

Yes, using this recipe tracetrail.phpΔ
Or, using an enhanced version of the same recipe tracetrail2.phpΔ

See the variables section for the only difference. BillReveile January 07, 2007, at 05:15 PM

Another version tracetrail3.phpΔ which remembers the trail history via a cookie - added by HansB June 23, 2008, at 04:50 PM


This recipe creates a list of recent visited local pages that have the markup (:tracetrails:). Only pages with that markup are saved. You can put the markup in the GroupHeader or GroupFooter to have all pages of a group to be listed in the history trails. The history is not group dependent. That means that all pages with the (:tracetrails:) markup will appear on the trail list whatever group it belongs.


Save the tracetrail.php into your cookbook directory.
Open local/config.php and add include_once("cookbook/tracetrail.php");
$GroupHeaderFmt = "(:tracetrails:)(:nl:)";
Add (:tracetrails:) to all Group-Headers or Footers in which you want to see the trail.

Note: You can add <!--wiki:$Group.$Name-GroupHeader $Group.GroupHeader $SiteGroup.GroupHeader--> to your skin where you want the Trail to be seen, if e.g. you have a design that needs the trail above the regular wikipages. But I couldn't find out yet, how to exclude the trail from the wikipage then, so you'll have it twice... the only chance I saw was to put (:nogroupheader:) on every page, but this is a very stupid solution...
And nogroupfooter in the header has no effect on the footer, so you can't put the trail in the footer and nogroupfooter in the header either Marvin October 19, 2006, at 12:45 PM


There are some variables that can be used to change the recipe's behaviour.

  • $TracePageFmt - Sets the name that will appear on the list. Defaults to '{$Group}/{$Name}'. Other page variables can be used. Ex. $TracePageFmt = '{$Fullname}';
  • $TraceLinkFmt - Sets the link format as will apear on th etrail. Defaults to '[[{$LinkPage} | {$PageName}]]'. The only variables that can be used here are $LinkPage and $PageName. $LinkPage is replaced by ResolvePageName($pagename) and $PageName is replaced by $pagename, being $pagename the name of each page saved in the trail.
  • $TraceSepFmt - The seperator used between each link in the trail.
  • $TraceCount - The number of pages to be displayed. Defaults to 5.
  • $TraceTrailFmt - The wraper for the trail list. Defaults to '<span class="wikitracetrail">{$TraceTrail}</span>'. The variable $TraceTrail is replaced by the trail list.

Also available in TraceTrail2.php

  • $TraceSkipCurr - Set to 1 to leave the current page out of the trail. Defaults to 0. The number of links is still controlled by $TraceCount. BillReveile January 07, 2007, at 05:15 PM

tracetrail3.php: additional variables and changes

The tracetrail list is kept as trace history in a cookie, so will be remembered from session to session.

  • $EnableTraceHistory - default true; set to 0 to disable cookie trace history.
  • {$Trace0}, {$Trace1}, {$Trace2}, {$Trace3} etc page variables for trace pagenames.
  • added ?action=cleartrace for deleting trace history (in session and cookie). Create alink with this for instant trace history deletion.
  • abandoned $TraceTrailFmt, set degfault separator to \n (newline) and set $TraceLinkFmt to * [[{$PageName}|+]] to produce a link list (of page titles) for use in SideBar or PageActions pages.
  • $TraceSkipCurr - default set to true, not showing current page with (:tracetrails:) markup.

-I used this in my sidebard with the Triad skin. All I had to do was put the markup (:tracetrails:) and it worked like a charm! I only wish that there was a way to get it to list side by side so I could use it in a footer. Anyway, the sidebar is great for now. Real Chris October 16, 2008, at 06:53 AM

How to put the trace on all pages ?

See GroupHeaders and put something like (note the new line and the "\\\")

$GroupHeaderFmt .= "(:tracetrails:)(:nl:)";

in your local/config.php.

Workaround to show trails in your header

'-I had a problem if i follow the instructions of the upper part the code breaks the layout of some pages like the one of PmWiki.BasicEditing, the span at the right dont shows properly in the default template, i spent a few hours how to work around this situation.

First of all set your GroupFooterFmt to in your config

$GroupFooterFmt = '(:nl:)(:include {$Group}.GroupFooter self=0 basepage={*$FullName}:)(:tracetrails:)';

This will make your site to show the trails but it lookes really ugly in the footer, well, keep reading...

Edit your tracetrail.php file and change the span tag for a div tag and set the id of the div to, lets say..., hiddentrails.


SDV($TraceTrailFmt, '<span class="wikitracetrail">Breadcrumbs{$TraceTrail}</span>');


SDV($TraceTrailFmt, '<div id="hiddentrails" style="display: none;"="hiddentrails">{$TraceTrail}</div>');

This will make our div invisible

Then edit your .tmpl file and put a new div, this div will show our menu

add to the body tag an onLoad command <body onLoad="showMenu()">

Paste the next script at the header section

<script type="text/javascript" language="JavaScript">
function showMenu(){

inner = document.getElementById('hiddentrails').innerHTML;
document.getElementById('menuTrail').innerHTML = inner;

And add the div to the position where you want to see the menu

I pasted it under the <div id='wikicmds'> section and it looks really nice <div class="menuTrail" id="menuTrail"></div>

Either this link is dead or its server is not running 11-05-2009 6:49 pkhg Well thats all hope it works-' Demo

I already posted this question to Hans in the Fox comments section, but just in case, maybe someone has a work around for this issue.


I'm using a Cookbook file called Tracetrail (which you are familiar with since you authored tracetrail3.php and is the version I chose to use). I have installed that php file in my wiki which is currently running on the Triad skin. Also, I just recently installed Fox because I wanted to have some of its functionalities and the shoutbox possibility ( Anyway, somehow whenever I leave Fox commented in my config.php somehow Trace Trail instead of giving me the sites I've been to only gives me a "+" on my wikisite. Whenever I uncomment Fox, and leave Trace Trail commented, Trace Trail works again and I can see the names of the links I've been to. Is there a work around for this issue? I'm also using PMWiki pmwiki-2.2.0-beta65, which of course is fairly recent.


Real Chris October 20, 2008, at 12:01 PM

Ok, since I got a response from Hans, I think its best that I post his response with my question just in case anyone else had that problem.

$TraceLinkFmt id set to '* '. try setting in config.php

$TraceLinkFmt = '* '; I do not see the connection with fox.php though. i though t the Pagename? markup syntax is generally defined in pmwiki, to show a page title rather than page name. HansB October 20, 2008, at 12:19 PM


Real Chris October 20, 2008, at 12:30 PM

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.