News Categories |
PmWiki /
Skin Templates‹ Skins | Documentation Index | Site Preferences › 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. Finding and Processing TemplatesWhen you set the value of the $Skin variable in a configuration file like ## Use the Foo Skin. $Skin = 'foo'; it tells PmWiki to search for a skin of that name, and use it. The usual result of the search is for PmWiki to load a template file from the appropriate skin directory. In this example, that would probably be the file The actual processing that PmWiki goes through to find a template file is important for those who are making complex skins, so its worth mentioning what those steps are: Security NoteThe default value for It has the side effect that its possible to construct a URL (like this one) that will let you look at the contents of the the Still, a purist might want to move their
Template file formatA template file is basically an HTML file that also contains variable substitutions (indicated by ‘$’) and special directives embedded in HTML comments. The following special directives are required in the template file.
When PmWiki displays a page, it replaces the directives and variable substitutions with the values appropriate to the current page. For example, the Note: your skin template shouldn’t have a <meta/> tag specifying the charset (encoding), as PmWiki adds this tag when needed. 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. Skin directivesBesides the required
The <!--wiki:Main.SomePage--> directive outputs the contents of Main.SomePage. $-substitutions are allowed in directives, thus a directive like <!--wiki:$Group.SomePage--> will include “SomePage” of the current group.
If multiple pages are listed in the directive, then only the first available page is used. Thus <!--wiki:$Group.SomePage Site.SomePage--> will display the contents of SomePage in the current group if it exists, and Site.SomePage if it doesn’t. To always display Site.SomePage, even if $Group.SomePage exists, use two consecutive <!--wiki:...--> directives.
The <!--wiki:...--> directive only displays pages for which the browser has read permissions. The <!--page:...--> directive displays pages even if the browser doesn’t have read permission.
The directive <!--file:somefile.txt--> outputs the contents of another file (on the local filesystem) at the point of the directive. If the file to be included is a .php script, then the PHP script is executed and its output is sent to the browser. Like the <!--wiki:...--> directive above, $-substitutions are available to be able to output files based on the current page name or group.
The markup directive processes any text that follows the colon as wiki markup and displays that in the output.
This directive calls a PHP function named “SomeFunction”, passing the current page’s name and the text following the function name as arguments. PHP functions called in this manner are typically defined in a local customization file. Args allows only one argument, which has to be splitted then. <!--function:SomeFunction arg1 arg2 arg3--> generates one parameter “arg1 arg2 arg3″. However variables can be used (like $LastModifiedBy).
Page sectionsA 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)"); And, better, compatible with PHP version 5.5, for PmWiki 2.2.58+ : Markup_e('noxyz', 'directives', '/\\(:noxyz:\\)/i', "SetTmplDisplay('PageXYZFmt',0)"); Internationalization (i18n)Skins can also be internationalized by using For example, the substitution Q How do I customize the CSS styling of my PmWiki layout? See Skins for how to change the default PmWiki skin. See also 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: $HTMLStylesFmt[] = '.foo { color:blue; }';
Q Where can the mentioned “translation table” be found for adding translated phrases? Q Is it possible to have the edit form in full page width, with no sidebar? If the sidebar is marked with Q Can I easily hide the Home Page title from the homepage? Yes, you can use in the wiki page either Q Is it possible to hide the Search-Bar in the default PmWiki Skin? Yes, please see Cookbook:HideSearchBar. ‹ Skins | Documentation Index | Site Preferences › This page may have a more recent version on pmwiki.org: PmWiki:SkinTemplates, and a talk page: PmWiki:SkinTemplates-Talk. |
Recent Comments