|
Cookbook /
Pagelist Template SamplesSummary: Custom templates for pagelists formats
Version:
Prerequisites:
Status:
Maintainer:
Sample custom formats for
fmt=#onelinecompact pagelist in one line.
[[#oneline]](:if ! equal {<$Group} {=$Group}:)
'''[[{=$Group}]] /''' \
(:if true:) | [[{=$FullName}|+]] \
[[#onelineend]]
fmt=#sidebarpagelist of titles for sidebar
[[#sidebar]](:if equal {<$Group}:)
>>fplsidebar<<
(:if ! equal {<$Group} {=$Group}:)
%sidehead%[[{=$Group}]](:if:)
* [[{=$FullName}|+]]
(:if equal {>$Group}:)
>><<(:if:)
[[#sidebarend]]
fmt=#sidebartitlespagelist of spaced page titles for sidebar, without group heading
[[#sidebartitles]](:if equal {<$Group}:)
>>fplsidebar<<(:if:)
* [[{=$FullName}|{=$Titlespaced}]]
(:if equal {>$Group}:)
>><<(:if:)
[[#sidebartitlesend]]
fmt=#forumforum topics in table format
[[#forum]]
(:if equal {<$Group}:)
(:table class=forum width="90%" :)
(:cell style="background:#e5e5ff;padding-left:5px" :)'''Topic'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''Last Posted'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''By''' (:if:)
(:cellnr style="background:#eeeeff;padding-left:5px" :)[[{=$FullName}|+]]
(:cell style="background:#eeeeff;padding-left:5px" :){=$LastModified}
(:cell style="background:#eeeeff;padding-left:5px" :)[[~{=$LastModifiedBy}]]
(:if equal {>$Group}:)
(:tableend:)(:if:)
[[#forumend]]
Use this option if you want to track the same contents as the real RecentChanges and you want a quicker rendering. If you do not use this option, the pagelist directive will read every page in your group which may take some time. This may also provide different information for pages modified externally to pmwiki. In either case, some info on deleted pages will not match the real RecentChanges.
If you want to change the layout for RecentChanges for all your groups, you can create a group called RecentChanges and insert a pagelist in the GroupHeader. This pagelist would use the group={$Name} option. Thereafter, instead of looking at Foo.RecentChanges, one would go to RecentChanges.Foo instead to see the custom RecentChanges.
fmt=#teasersInclude the first five lines of every page preceded by an edit link for that page
[[#teasers]]
|| '''[[{=$FullName}]]''' - [[Edit -> {=$FullName}?action=edit]]||
(:include {=$FullName} lines=4:)
(:if ! equal {>$Group}:)
-----
(:if:)
[[#teasersend]]
fmt=#headerincludeInclude the first paragraph. This allows a more flexible way to get teasers.
[[#headerinclude]]
%rfloat%[-more-] [[{=$FullName}|{=$Titlespaced}]]
(:include {=$FullName} para=1:)
(:if equal {>$Group}:)
(:title {$Title}:)(:if:)
----
[[#headerincludeend]]
fmt=#articleteaserA modification of the 'teasers' template showing how css elements can be used.
[[#articleteasers]]
[+{=$Title}+]
%define=leftborder border-left="2px solid #88f" margin-left="2px" padding="0 0 0 10px"%
>>leftborder<<(:include {=$FullName} lines=5:)
%right% [-[[{=$FullName}|Read More]]-]
(:if ! equal {>$Group}:)
>><<
(:if:)
[[#articleteasersend]]
fmt=#includeTitleInclude whole pages, with titles as links to the pages, separated by a horizontal rule underneath each page's content. An edit link is shown if the user is authorized as editor. The title header for each page also contains an anchor which is the same as the full page name, used for #includeToc below.
[[#includeTitle]]
(:if auth edit:)
%rfloat%[[{=$FullName}?action=edit|[-edit-]]](:if:)
!![[#{=$FullName}]][[{=$FullName}|{=$Title}]]
(:include {=$FullName}:)
----
(:if equal {>$Group}:)
(:title {$Title}:)(:if:)
[[#includeTitleend]]
For example, to include the Foo pages in a group: (:pagelist group={$Group} name=Foo* order=title fmt=PagelistTemplateSamples#includeTitle:) fmt=#includeTocBuild a table of contents for the included pages included by #includeTitle above.
[[#includeToc]]
* [[#{=$FullName}|{=$Title}]]
[[#includeTocend]]
So, to include all the Foo pages in a group, starting with a table of contents:
(:pagelist group={$Group} name=Foo* order=title fmt=PagelistTemplateSamples#includeToc:)
----
(:pagelist group={$Group} name=Foo* order=title fmt=PagelistTemplateSamples#includeTitle:)
fmt=#groupsWithListLinksA bullet list of groups, with a link for listing the pages in that group.
[[#groupsWithListLinks]]
(:if ! equal {=$Group} {<$Group}:)
* [[{=$Group}]] \
([[list pages -> {$Name}?action=search&q=group%3D{=$Group}]])
(:ifend:)
[[#groupsWithListLinksend]]
fmt=#bygrouptitleA list with group-names and titles (especially for a customized searchlist)
[[#bygrouptitle]]
(:if ! equal {=$Group} {<$Group}:)
:[[{=$Group}/]] /:
(:if:)
: :[[{=$Group}/[[{=$Name} | + ]]
[[#bygrouptitleend]]
fmt=#includeXrefThis is a generalization of the #includefaq format. Include a section from a page which has an anchor with the same name as the current page your pagelist is on.
[[#includeXref]]
(:include {=$FullName}#{$Name}:)
[[#includeXrefend]]
So, for example, if I have an anchor here:
Then I could include only that section by doing this:
fmt=#excerptsTo include an extract of the page text around the search term, as Google does. This makes use of Cookbook:Excerpts and Cookbook:SearchQueryVariable without using Cookbook:SortByScore. You can make this format default for searches (and not pagelists, where it does nothing) by setting
fmt=#categorizedIn order to list all pages belonging to a particular category
fmt=#colorbydateA simple bullet list of page names. Colored red if within last 7 days, blue if within last 30 days, green if older.
[[#colorbydate]]
* (:if date {$TodayMinus7}..{$TodayYMD}
{=$LastModifiedYMD}:)%red%(:elseif date {$TodayMinus30}..{$TodayYMD}
{=$LastModifiedYMD}:)%blue%(:else:)%green%(:ifend:) [[{=$FullName}]] modified: {=$LastModifiedYMD}%%
[[#colorbydateend]]
colorbydate requires the following lines in config.php:
$FmtPV['$TodayMinus7'] = '"' . strftime("%Y-%m-%d", $Now-(7*24*60*60)) . '"';
$FmtPV['$TodayMinus30'] = '"' . strftime("%Y-%m-%d", $Now-(30*24*60*60)) . '"';
$FmtPV['$TodayYMD'] = '"' . strftime("%Y-%m-%d", $Now) . '"';
$FmtPV['$LastModifiedYMD'] = 'strftime("%Y-%m-%d", $page["time"])';
The output would look something like this (assuming it was run on 2008-07-13):
fmt=#sidebarexpandthisgroupAn attempt to display all groups with the current group expand to show all pages. The current group and page should be highlighted. Improvements to this template would be much appreciated. Rik Blok? November 07, 2009, at 01:52 PM
(:if1 false:)
[[#sidebarexpandthisgroup]]
(:template first {=$Group}:)
(:if2 group {=$Group} :)
* %sidehead% [[{=$Group}/]]
(:else2:)
* [[{=$Group}/]]
(:if2end:)
(:template each:)
(:if2 equal {*$Group} {=$Group}:)
(:if3 name {=$FullName} :)
** (:comment Empty item so sidehead isn't applied to full list if this is first item :)
** %sidehead% [[{=$FullName}|{=$Titlespaced}]]
(:else3:)
** [[{=$FullName}|{=$Titlespaced}]]
(:if3end:)
(:if2end:)
[[#sidebarexpandthisgroup]]
(:if1end:)
Notes
CommentsSee Also
Contributors |