Summary: Extend the (:include:) markup to allow passing parameters to included pages.
Version: 20191107
Prerequisites: PmWiki >= 2.2.58
Status: beta
Maintainer: None (original author: Mateusz)
  • Not to be confused with Edit Templates.
  • The recipe unfortunately uses the same directive (:template ...:) as the core PageLists which might lead to confusion. The directive from this recipe will cause problems if placed inside a pagelist template.
  • PmWiki supports (since Version 2.2.0 beta) parameter passing to (:include:) pages, see IncludeOtherPages, but this add-on uses Wikipedia-style markup for the variables with default values (a feature PmWiki lacks).


How can I pass some parameters to the pages I (:include:), like it's done in Wikipedia?


The templates.phpΔ script is a PmWiki plugin, which provides new (:template:) markup. This markup extends standard (:include:) markup by allowing parameters to be passed to the included pages. Those parameters can be then referenced by additional markup, looking like this: {{{parameter-name}}}.


This recipe extends the standard behaviour of the (:include:) markup. It does so by adding new markup -- (:template:) -- which is like the previous one, but it allows the passing of some parameters. A simple example may be the Template "BookCard" which is located in the "Templates" group:

Some books I like:

(:template Templates.BookCard title='The Holy Bible' note='important':)
(:template Templates.BookCard title='The Lord of the Rings' note='fantasy':)

Then, in the template, you can reference those parameters using the markup of {{{parameter-name|default value}}}. For example, your Templates.BookCard page might look like:

* {{{title}}} ''(note: {{{note|---}}})''

And then, the first page after saving would look like:

Some books I like:

  • The Holy Bible (note: important)
  • The Lord of the Rings (note: fantasy)


This script is installed in the standard way:

  1. download the file templates.phpΔ and save it in your cookbook directory,
  2. activate the plugin by adding the line below to your 'local/config.php' file:
    include_once( 'cookbook/templates.php' );


  • This recipe was last tested on PmWiki version: 2.2.120
  • This recipe was first tested on PmWiki version: 2.1.11
  • This recipe requires at least PmWiki version: 2.2.58

  • Internally, the recipe uses also two directives: (:set-parameters:) and (:unset-parameters:), so those two names should not be redefined.
  • I'm not sure if it's good that I posted this recipe. That's because I suppose it's possible that used a lot, this recipe might make a site run considerably slower. I think that the classic way -- creating Markup() entries -- is the better one (the faster one). But then, this way is certainly the easier one -- as much more can be done on-wiki, without the need to work with the code.

Known Issues and Notes

  • You must not use double quotes in parameters -- that is, (:template Foo param1="some thing":) will not work properly; you must use single quotes, (:template Foo param1='some thing':) instead.
    • Seems there are a bit more issues with quotes and slashes, because of so-called "PHP slashes magic". The solution seems to be to use the PSS() function in the recipe; I'll try to solve that when I have some more time. (~Mateusz)
    • Wiki-Text in the passed parameters may be processed except ''italics'' and '''bold''' (the first single quote will be recognized as end-of-parameter).
    • End of line must use [[<<]] instead of \\.

See Also

More Wikipedia


  • Mateusz - if you are having issues with the recipe, when emailing the mailing list please send me a copy of your email (I'm not actively reading the list).

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 2006-06-24 (version 1.0) - initial version.
  • 20191107 : updated for PHP 5.5-7.2, requires PmWiki 2.2.58 or newer (Petko)


User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.