PmWiki: LayoutAdvanced

As described in the LayoutBasics page, HTML based templates can be used to customize the layout and appearance of Wiki pages. Template files can include links to external stylesheets (.css files). This page explains how template files are processed and how CSS files are included.

Templates: Directives and Variables

HTML comments can be included in templates, for example: <!-- this is a comment -->. Some comments work as directives that have special significance. There are no spaces between the comment delimeters and the keywords; that is, <!--PageText--> is valid, but <!-- PageText --> is not. Available directives and variables are:

<!--PageText-->
This indicates where the content of the current Wiki page should be inserted.

<!--HeaderText-->
This directive allows PmWiki to insert appropriate meta tags into the <head> section of the HTML output (used to control indexing by search engines). PmWiki will also check for the existence of relevant CSS files in pub/css; $Group.css and $Group.$Title.css will be included here if they exist.

Include a Wiki page: <!--wiki:Main.SomePage-->
Use this type of directive to include a Wiki page. For example, if you have a sidebar, you could include it using <!--wiki:Main.SideBar-->.

Call a PHP function: <!--function:SomeFunction-->
You could use this to call a function you defined in your local/config.php which may print out different text based on, say, the current page or group.

<!--Page...Fmt--> directives
A directive in this form (ie. starting with "Page" and ending with "Fmt") indicates the beginning of a section of the template. The section that follows is placed in a variable by the same name. For example, <!--PageFooterFmt--> indicates the start of a footer which is stored in the $PageFooterFmt variable. The section continues until the next <!--Page...Fmt--> directive, or the end of the file. It is also possible to indicate the end of a section using <!--/Page...Fmt-->. Note that, by default, only $PageHeaderFmt, $PageFooterFmt and $PageTitleFmt are included in the output when a WikiPage is viewed. Other variables can be defined and used, but they will only appear in certain situations. For example, <!--/PageEditFmt--> can be used to define a section that only appears when the Edit action is in use (ie. a page is being edited).

Including variables
PHP variables are evaluated when PmWiki processes a template file. For example, you can insert a logo using $PageLogoFmt, or create an Edit Page link using <a href='$PageUrl?action=edit'>$[Edit Page]</a>

<< LayoutBasics | PmWiki.DocumentationIndex | PerGroupCustomizations >>
本頁更新於 2004 年 06 月 23 日,06:08 PM