Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

TraceTrail

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

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

Description

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.

Installation:

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

Notes

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.

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.

From

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

To

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;
}
</script>

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>

Well thats all hope it works-' Demo http://rootshell.be/~jeditec/pmwiki/pmwiki.php?n=PmWiki.BasicEditing

Edit - History - Print - Recent Changes - Search
Page last modified on June 23, 2008, at 05:06 PM