|
Cookbook /
PageListTemplatesQuestionHow can I customize the layout of a pagelist output in a wiki page? AnswerThis recipe is now deprecated. From version 2.1.beta15, PmWiki has improved builtin Pagelist templates. See PagelistsExplained?
include_once("cookbook/pltemplates.php");
Example:
(:pagelist fmt=template page=PageList.Main group=Main:)
Templates:To define a template, simply create a wiki page with standard wiki markup that will be included once for each page in the pagelist. This template can be used to define the layout of your pagelist output. Custom variables:Additional custom page variables are defined in this recipe which will get set appropriately on every page returned. Use these variables to output the fullnames of the current, previous or next page. With these fullnames and the PageVariables recipe you can get values such as the name and group of these pages. You can also test for conditions using the names and groups which may influence your markup, such as at the beginning of a new group. {$Curr} - FullName of page from current iteration
{$Prev} - FullName of page from previous iteration
{$Next} - FullName of page from next iteration
{$PageCount} - The current page count
{$GroupPageCount} - The current page count within this group
{$GroupCount} - The current group count
Note: these variables have been kept to a minimum, due to the new PageVariables recipe.
Additional Conditions:This recipe provides two additional conditions which are very valuable when using this recipe: equal - Test whether a value is equal to another value
divisible - Test whether a number is divisible by another number
Additional Markup:%omit-quest% Since it is common for pagelists to reference Group pages (such as Group.HomePage) that might not exist, this new markup has been included to suppress any questions marks for non-existing pages. Simply use the markup before any link specification which may be to a non-existing wiki page. Blank page variables with {$Prev} and {$Next}: Since {$Prev} and {$Next} can be blank, there is markup causing page variables with blank {$Prev} and {$Next}s to also be blank. This is particularly usefull in conditional statements. This makes $Group} blank if {$Prev} is blank. Without this markup, a blank {$Prev} would cause $Group} to return the current group which is probably not what was desired. Blank links with [[{$Prev}]], [[{$Next}]] or blank page variables: There is also some additional markup defined to hide blank links which the {$Prev}, {$Next} or the ensuing blank page variables might create. This means that [[]] will be invisible instead of outputting strange markups on the first iteration. Simple Examples:Most of these assume that you have the PageVariables recipe installed.
(:if equal {$Prev} :)
(:if ! equal {{$Curr}$Group} {{$Prev}$Group} :)
(:if ! equal {{$Curr}$Group} {{$Prev}$Group} :)
%omit-quest%[[{{$Curr}$Group}(.HomePage)]] /
(:if:)
->[[({{$Curr}$Group}.){{$Curr}$Name}]]
While this sets up layout info, the styling may be different from fmt=byGroup since this does not output any CSS classes. Also, non-existent groups will actually be linked with ?action=edit even though the question mark will be omitted (this might be an improvement). Notes and Comments
I'm not sure what you are suggesting for MailPosts. Are you suggesting formatting the contents of the email by template? - Martin Fick
Versions2005-12-05 : version 2.0 - Martin FickThis version will break compatibility with all previous versions! Do not upgrade to this unless you are prepared to redesign your templates.
2005-10-26 : version 1.3 - Martin Fick
2005-10-23 : version 1.2a - Daniel Scheibler
2005-10-22 : version 1.2 - Daniel Scheibler
2005-09-18 : version 1.1 - Martin Fick
2005-09-16 : version 1.0 - Martin Fick
See AlsoContributors |