|15 Aug 2020||Birmingham Inventors / PmWiki / SkinTemplates|
This page describes the skin template files (.tmpl) that are used to create PmWiki skins, and how PmWiki uses them. As described in the skins page, a skin is a collection of files that specifies the layout for PmWiki pages. Each skin must include a template file that provides the skeleton for displaying a PmWiki page.
PmWiki processes any skin.php file in the skin directory before loading any templates. If there is no skin.php file, or if the skin.php file doesn't load a template, then PmWiki falls back to looking for a template with the same name of the skin, or a single .tmpl file if it exists.
In simpler setups (which is what the vast majority of skins have), the skin.php file is absent or makes no mention of the .tmpl file, and so PmWiki finds and loads the template itself. To exert greater control over the process, simply call LoadPageTemplate() inside the skin.php file, with the name of the .tmpl file to be loaded:
For example, a skin might specify a special template to be used if the action is 'print':
When the action is something else, the default skin gets loaded instead.
Template file format
A template file is basically an HTML file that also contains variable substitutions (indicated by '$') and special directives embedded in HTML comments. Two special directives are required in the template file. The directive
There is also an optional
When PmWiki displays a page, it replaces the directives and variable substitutions with the values appropriate to the current page. For example, the
There is a long list of variables available for substitution in pages; some of the most useful include:
$PageUrl the url of the current page $ScriptUrl the base url to the pmwiki.php script $Title the page's title (e.g., "`SkinTemplates") $Titlespaced the page's title with spaces (e.g., "Skin Templates") $Group the name of the current group (e.g., "`PmWiki") $FullName the page's full name (e.g., "`PmWiki.SkinTemplates") $LastModified the page's last modification time $PageLogoUrl the url of a site logo $WikiTitle the site's title $SkinDirUrl the url of the skin's folder
This last variable,
The template is not limited to using the variables listed here; nearly any PHP global variable that begins with a capital letter can be used in a skin template. Page variables can also be used in templates.
Besides the required
A template file can designate "sections" that are included or excluded from the output based on page directives or other criteria. A section always begins with
<!--PageHeaderFmt--> (:noheader:) <!--PageFooterFmt--> (:nofooter:) <!--PageTitleFmt--> (:notitle:) <!--PageLeftFmt--> (:noleft:) <!--PageRightFmt--> (:noright:) <!--PageActionFmt--> (:noaction:)
Skin designers can define custom sections and markups, but currently all section names in the template must begin with "Page" and end with "Fmt". As mentioned you also have to define the corresponding markup (for example in your config.php) like this:
Markup('noxyz', 'directives', '/\\(:noxyz:\\)/ei', "SetTmplDisplay('PageXYZFmt',0)");
Skins can also be internationalized by using
For example, the substitution
See Skins for how to change the default PmWiki skin. See also Cookbook:Skins, where you will find pre-made templates you can use to customize the appearance of your site. You can also create a file called local.css in the pub/css/ directory and add CSS selectors there (this file gets automatically loaded if it exists). Or, styles can be added directly into a local customization file by using something like:
Where can the mentioned "translation table" be found for adding translated phrases?
|Validate the XHTML and CSS of this page.||Page last modified on 23 Sep 2006||Edit History Print Recent Changes|
Powered by PmWiki