|
Cookbook /
DynamicWikiTrailsSummary: Define dynamic URL trails
Version: 2.2 - 24 March 2007)
Prerequisites: Last tested on PmWiki version: 2.2.0-beta35
Status:
Maintainer: Martin Fick, JamesM
Discussion: DynamicWikiTrails-Talk
Categories: Administration, WikiTrails
Question
AnswerDefine dynamic URL trails with this recipe: Note: For question # 2 you will need to use the Group Header/Footer Trail markup mentioned near the end.
PmWiki Versions prior to 2.2.0 Add this markup and condition to your config.php Markup('{$Trail}','>{$fmt}', '/{\\$(Trail)}/e', "\$_REQUEST['$1']");
$Conditions['trail'] = "isset(\$_REQUEST['Trail'])";
Markup('(:trailindex:)','directives', '/\(:trailindex:\)/e', "addtrail()");
function addtrail() { global $AddTrail; $AddTrail = TRUE; return ""; }
PmWiki Versions 2.2.0 and later Add this markup and condition to your config.php $FmtPV['$Trail'] = "\$_REQUEST['Trail']";
$Conditions['trail'] = "isset(\$_REQUEST['Trail'])";
Markup('(:trailindex:)','directives', '/\(:trailindex:\)/e', "addtrail()");
function addtrail() { global $AddTrail; $AddTrail = TRUE; return ""; }
All known PmWiki versions Patch your pmwiki.php (carefull!)To the LinkPage() function:
function LinkPage($pagename,$imap,$path,$title,$txt,$fmt=NULL) {
global $QueryFragPattern,$LinkPageExistsFmt,$LinkPageSelfFmt,
$LinkPageCreateSpaceFmt,$LinkPageCreateFmt,$FmtV,$LinkTargets,
$AddTrail;
if ($AddTrail) $qf .= $qf ? "&":"?" . "Trail=$pagename";
$fmt = str_replace(array('$LinkUrl', '$LinkText'),
array(PageVar($tgtname, '$PageUrl').PUE($qf), $txt), $fmt);
return FmtPageName($fmt,$tgtname);
}
To the MarkupToHtml() function:
function MarkupToHTML($pagename, $text, $opt = NULL) {
# convert wiki markup text to HTML output
global $MarkupRules, $MarkupFrame, $MarkupFrameBase, $WikiWordCount,
$K0, $K1, $RedoMarkupLine, $AddTrail;
$AddTrail = FALSE;
Seed your wiki trail on the trail index page with the new (:trailindex:) directivei.e. (:trailindex:) * [[Group.Page1]] * [[Group.Page2]] * [[Group.Page3]] ... This will make every link to a page have the following arguments inconspiculously added to them: ?Trail=<trailindexpage> Define a Pagelist Template with your wiki trail markup.
----
!!!fmt=#trail
This template simulates the regular trail markup
([[http://www.pmwiki.org/wiki/Cookbook/DynamicWikiTrails|DynamicWikiTrails]])
[=
[[#trail]]
(:if equal {*$FullName} {=$FullName} :)
<[[{<$FullName}?Trail={$$trail}|{<$FullName}]] |\
[[{$$trail}]] |\
[[{>$FullName}?Trail={$$trail}|{>$FullName}]]>
(:if:)
[[#trailend]]
=]
----
!!!fmt=#trailtitled
This template uses page titles instead of pagenames
([[http://www.pmwiki.org/wiki/Cookbook/DynamicWikiTrails|DynamicWikiTrails]])
[=
[[#trailtitled]]
(:if equal {*$FullName} {=$FullName} :)
<[[{<$FullName}?Trail={$$trail}|{<$Title}]] |\
[[{$$trail}|{{$$trail}$Title}]] |\
[[{>$FullName}?Trail={$$trail}|{>$Title}]]>
(:if:)
[[#trailtitledend]]
=]
----
!!!fmt=#trailSideBar
This template can be used in a sidebar to show the current trail index along
with the current page highlighted in the sidebar. Can also be used to simply
list a trail contents for a specific trail.
([[http://www.pmwiki.org/wiki/Cookbook/DynamicWikiTrails|DynamicWikiTrails]])
[=
[[#trailSideBar]]
(:if equal {<$FullName}:)
! [[{$$trail}|{{$$trail}$Title}]]
(:if ! equal {*$FullName} {=$FullName} :)
* [[{=$FullName}?Trail={$$trail}|{=$Title}]]
(:if equal {*$FullName} {=$FullName} :)
* [[{=$FullName}?Trail={$$trail}|'''{=$Title}''']]
(:if:)
[[#trailSideBarend]]
=]
Define a Dynamic Trail Markup on Pages in the TrailThe dynamic trail markup can look like this: (:if trail:)(:pagelist trail={*$Trail} fmt=<templatepage>#trail:)(:if:)
where <templatepage> refers to the page where you defined your trail markup in the previous step, or leave it blank if you used Site.LocalTemplates.
You can also specify a trail to list the index for like this: (:if trail:)(:pagelist trail=Group.PageName fmt=<templatepage>#trail:)(:if:) Version History
Features
Example
See Also
Contributors
CommentsSee discussion at DynamicWikiTrails-Talk 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. |