SkinTemplates-Talk

Is there any way to make "cabbage nesting" of templates?

For example, for skin "MySkin" it could be done like that:

  • MySkin-header.tmpl
  • MySkin-default.tmpl | this is base default skin, which includes header & footer
  • MySkin-GroupName.tmpl | this skin applied automatically for GroupName?, instead of default part.
  • MySkin-footer.tmpl

Additionally, all SkinTemplates directives can be used as usual.

Is there any way to make something like this?

Finar March 05, 2019, at 05:04 PM

You can have a different template loaded conditionally. You need to have a skin.php file that will load the alternative template if it exists:
$template = FmtPageName('MySkin-{$Group}.tmpl', $pagename);
if(! file_exists("$SkinDir/$template"))
  $template = 'MySkin.tmpl'; # default
LoadPageTemplate($pagename, "$SkinDir/$template");
$IsTemplateLoaded = 1;

You cannot easily break the template into header, footer and other sections loaded from external files. --Petko March 08, 2019, at 12:56 PM

I've added this feature for 2.2.114, you can get the pre-release as a ZIP file from the ChangeLog page, or via Subversion. See the documentation at SkinTemplates#directives and $SkinTemplateIncludeLevel. --Petko March 09, 2019, at 10:30 AM

Greate, Petko, many thanks! Finar

Understanding old config files

This information is deprecated, but we're still including it in the docs so you can better understand any really old local/config.php files you look at.

The original method of telling PmWiki where to find a skin used to be to set $PageTempateFmt to the path of a .tmpl file on the server. This is still respected by PmWiki, so if, for example, you were to set $PageTemplateFmt to ./pub/skins/foo/foo.tmpl then PmWiki would simply load and use that file, but without setting the special $SkinDir and $SkinDirUrl variables that are required by all modern skins.

DO NOT USE $PageTemplateFmt

How to do conditional output in skin?

Note that the following code, correct in a wiki page (without the "<!--markup:") doesn't work in a skin. <!--markup:(:if ! equal "{$LastModifiedBy}" "":)--> by {$LastModifiedBy} This is display everytime <!--markup:(:ifend:)--> (To continue to answered with a solution)

How to properly use the <!--file:path/somefile.php-->

in order to be able to php include a file that is hosted outside the pmwiki directory.
I want my template to have a php include to my site's footer php file so that it can be dynamic. Thank you.

You have to keep your php file where your pmwiki.php file is, so it can be automatically included or use the full path to your file with the "file:" skin directive.

How can I insert javascript in the skin template ? When I try to do so, it seems that the Javascript is turned off. I'm missing something but I'm an amateur.

I've the same problem. Somebody please tell us something about, thanks.

There is no problem using JS, it can be used like in regular static .html file. Please provide more details to get help. What exactly is not working? Finar April 20, 2017, at 08:06 AM

For that matter is there any sort of programming language you can use in a template file?

Earlier I wrote some javascript to check if the page was being edited, and if so not display a sidebar, but ran into the problem above me. Are these files parsed with PHP? Or is there a way to use those embedded HTML comments mentioned in the article to accomplish what I mentioned?

Is there a way to replace <!-- PageText --> with mark up? I'd like to make one skin template with conditional markup based on action instead of several templates switched by action. I could do this in <!--markup: ... --> if I had a different way of including PageText.

See the variable $ActionSkin: lets you select a separate template based on the action. Every template can include the common parts from other files with <!--file:header.tmpl-->. --Petko April 21, 2017, at 03:16 AM

Is there any way to find out current phisical file path is being processed and use it in the skin? I want to know if current page is placed in "wiki.d" or "wikilib.d" directory and use this information in the template in any way. Thanks! Finar April 20, 2017, at 08:06 AM

Sorry, no, there is no such Skin variable. --Petko April 21, 2017, at 03:16 AM

This is a talk page for improving PmWiki.SkinTemplates.