SkinTemplates-Talk
How to make markup output with no <p> wrapping?
In my template I want to make layout like this:
<div class='<!--markup:(:if %my tricky condition%:)show(:else:)hide(:ifend:)-->'>...</div>
But this way I get HTML like <p>show</p>
witch is not correct. What is the best way to avoid this? Finar May 03, 2020, at 02:16 PM
There is no easy way to avoid this without breaking many things on your website. Instead of this, use <!--wiki:{$Group}.SomePage Site.SomePage-->
where you output the content conditionally. --Petko May 12, 2020, at 02:05 PM
I've found one way. It is not beautiful, but it is better then nothing and I think better then wiki: on big templates with lot's of conditions. Add this to config.php:
Markup("plainText",'block',"/@plain@(.*?)@plain@/",'<:block,1>$1');
Then in template use:
<!--markup:@plain@(:if %my tricky condition%:)show(:else:)hide(:ifend:)@plain@-->
or for example:
<!--markup:@plain@{Site/SkinConfig$:Container}@plain@-->
This give you possibility to make visual skin-config wiki-pages with params as PTVs.
And of course you can change @plain@ to something you prefer.
Finar May 12, 2020, at 02:22 PM
Excellent solution. --Petko May 12, 2020, at 06:13 PM
What is the current way to create common *.tmpl templates for several skins?
For example, I have a WikiFarm with 2 skins: MySkin1 & MySkin2.
I use $SkinTemplateIncludeLevel
and I made MyModalWindow.tmpl file with code like this:
HTML-HTML-HTML... <!--markup: ...some WIKI markup doing important things... --> HTML-HTML-HTML...
Now I want both MySkin1 & MySkin2 include this only one MyModalWindow.tmpl code. Is it possible?
Probably should I create a Cookbook php-module for that? If so, I don't know how to make wiki-markup being processed from PHP...
Finar July 29, 2019, at 05:13 PM
Currently PmWiki doesn't allow including templates outside of the active skin folder, otherwise people may be able to include config or passwd files. If you want both skins to include the same file, you could probably create a symbolic or hard link from one of the skin folders to the other. For example:
pub/skins/MySkin1/MyModalWindow.tmpl (original) pub/skins/MySkin2/MyModalWindow.tmpl (symbolic or hard link)
See [1] for instructions for GNU/Linux servers if you have a shell, otherwise see if your FTP client allows you to do this. --Petko July 29, 2019, at 05:42 PM
Instead of <!--markup: ...-->
you could use <!--wiki:Site.SomePageWithTheMarkup-->
in both skins and place your markup there. The page needs to be readable for everyone, and pages in Site.* are usually so. --Petko July 29, 2019, at 05:48 PM
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
$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
Understanding old config files
local/config.php
files you look at.
The original method of telling PmWiki where to find a skin used to be to set $PageTemplateFmt
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
and $SkinDir
variables that are required by all modern skins.
$SkinDirUrl
$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.