Summary: Dynamic WikiTrails with pagelist
Version: 1
Prerequisites: pmwiki 2.1
Status: experimental
Maintainer:
Questions answered by this recipe
How can I create a trail through the pages of a group without having a trailpage?
This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.
Description
Add the following pagelist template formats to your Site.LocalTemplates
and pagelist trail markup to the group's GroupHeader or GroupFooter page:
Dynamic trail of form prev.Name | Group | next.Name
[[#grouptrail]]
(:template each :)
(:if equal {*$FullName} {=$FullName}:)
%wikitrail%[[{<$FullName}|+]] | [[{*$Groupspaced}]] | [[{>$FullName}|+]]
(:ifend:)
[[#grouptrailend]]
(:pagelist group={*$Group} fmt=#grouptrail :)
Dynamic trail of form <<prev | Group | next>>
[[#grouptrail2]]
(:template each :)
(:if equal {*$FullName} {=$FullName}:)
%wikitrail%[[{<$FullName}| « prev ]] | [[{*$Groupspaced}]] | [[{>$FullName}| next » ]]
(:ifend:)
[[#grouptrail2end]]
(:pagelist group={*$Group} fmt=#grouptrail2 :)
The trail markup will link to previous and next pages in the group, and to the group's homepage. The group's homepage does not need to contain a list of pages, the pagelist markup is generating the trail links.
To make sure that RecentChanges and GroupFooter don't show up in the navigation when using the Dynamic Trails recipe use the list=normal option , eg
(:pagelist group={$Group} fmt=#grouptrail list=normal :)
Note that list=normal in up-to-date versions of pmwiki causes the current page to not occur in the list, rendering this recipe non-operational. See note on $SearchPatterns below for a better solution. —Peter Bowers August 07, 2010, at 04:28 PM
To understand the use of the "*$" markup see page variable special references and pagelist template special references.
Variation: fmt=#nextontrail
Dynamic trail of form NextPageName link
[[#nextontrail]]
(:if equal {*$FullName} {=$FullName}:)
Next page: [[{>$FullName}|+]]
(:ifend:)
[[#nextontrailend]]
(:pagelist group={*$Group} fmt=#nextontrail list=normal:)
Notes
Release Notes
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
Comments
Note that this recipe may not work for you if (:pagelist:) is set to not return the current page in its results,
Normally this would be fixed by modifying $SearchPatterns in your config.php.
2008-10-05
I'm currently using this recipe on my site for Dynamic trail of form <<prev | Group | next>> but I made a small change to replace the "prev" and "next" with the page names of the prev and next pages. The change I made:
Replace this
%wikitrail%[[{<$FullName}| « prev ]] | [[{*$Groupspaced}]] | [[{>$FullName}| next » ]]
with this
%wikitrail%[[{<$FullName}| « {<$Namespaced} ]] | [[{*$Groupspaced}]] | [[{>$FullName}| {>$Namespaced} » ]]
The only problem I'm having with this recipe is that list=normal results in hiding the trail, even with the default template. The only workaround I can find is to use (:pagelist group={*$Group} name=-GroupHeader,-GroupFooter fmt=#grouptrail:) to remove certain pages from the pagelist. It works so it's not a big problem. Ian MacGregor
list=normal excludes the current page. You must either change your definition of $SearchPatterns['normal'] or, preferably, define a new pattern with this line(s) in config.php:
$SearchPatterns['trail'] = array('recent' => '!\.(All)?Recent(Changes|Uploads)$!',
'group' => '!\.Group(Print)?(Header|Footer|Attributes)$!');
then in your pagelist markup use list=trail (:pagelist ... list=trail:) —Peter Bowers August 07, 2010, at 04:28 PM
The syntax given above is a bit different from that in the
SearchPatterns recipe, which shows the following:
$SearchPatterns['normal'][] = '!\.(All)?Recent(Changes|Uploads)$!';
$SearchPatterns['normal'][] = '!\.Group(Print)?(Header|Footer|Attributes)$!';
From this, I infer that the trail search pattern could be specified as:
$SearchPatterns['trail'][] = '!\.(All)?Recent(Changes|Uploads)$!'; # don't list change pages
$SearchPatterns['trail'][] = '!\.Group(Print)?(Header|Footer|Attributes)$!'; # don't list GroupHeader, GroupFooter, GroupAttributes
$SearchPatterns['trail'][] = '!\.Template.*$'; # don't list pages like Cookbook.Template
$SearchPatterns['trail'][] = '!^Profiles\..*-Contrib$!'; # don't list pages with author's contributions
$SearchPatterns['trail'][] = '!-Talk$!'; # don't list pages that end in -Talk
Do the sub-array elements' names matter? (I.e. $SearchPattern['trail']['recent'] and $SearchPattern['trail']['group'])
--
tamouse September 19, 2011, at 09:37 AM
2010-08-07 Peter Bowers
I prefer using $Titlespaced as seemingly the most user-friendly view of the name of the page. Here's my definition:
[[#navigate]]
(:template each :)
(:if equal {*$FullName} {=$FullName}:)
[[{<$FullName}|« {<$Titlespaced}]] | '''{*$Titlespaced}''' | [[{>$FullName}|{>$Titlespaced} » ]]
(:ifend:)
[[#navigateend]]
2009-07-16
Found a way to have looping trails. Here how I did it:
[[#grouptrail3]]
(:template first:)
(:if equal {*$FullName} {=$FullName}:)
(:pagelist link={$$link} order=-name count=1 fmt=#grouptrailHelper PrevName="" IndexName={*$Groupspaced} NextName={>$FullName}:)
(:ifend:)
(:template each:)
(:if equal {*$FullName} {=$FullName}:)
(:if2 ! equal {<$FullName} ".":)
(:if3 ! equal {>$FullName} ".":)
%wikitrail%< [[{<$FullName}]] | [[{*$Groupspaced}]] | [[{>$FullName}]] >
(:if3end:)
(:if2end:)
(:ifend:)
(:template last:)
(:if equal {*$FullName} {=$FullName}:)
(:pagelist link={$$link} order=name count=1 fmt=#grouptrailHelper PrevName={<$FullName} IndexName={*$Groupspaced} NextName="":)
(:ifend:)
[[#grouptrail3end]]
[[#grouptrailHelper]]
(:if equal {$$PrevName} "":)
%wikitrail%< [[{=$FullName}]] | [[{$$IndexName}]] | [[{$$NextName}]] >
(:else:)
%wikitrail%< [[{$$PrevName}]] | [[{$$IndexName}]] | [[{=$FullName}]] >
(:ifend:)
[[#grouptrailHelperend]]
>><<
See Also
Contributors
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.