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}}}.

PmWiki supports (since Version 2.2.0 beta) parameter passing to (:include:) pages, see IncludeOtherPages.

Summary: Extend the (:include:) markup to allow passing parameters to included pages.
Version: 1.0
Prerequisites: pmwiki >= 2.1.11 (or less?)
Status: beta (just released)
Maintainer: Mateusz


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.1.11
  • This recipe was first tested on PmWiki version: 2.1.11
  • This recipe requires at least PmWiki version: ???

  • 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.


User notes? : 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.