Summary: Combines a template page with a data page to present PmWiki content
Version: 1.0rc - initial release
Prerequisites: PmWiki 2.1
Status: RC
Maintainer: Octocias
Discussion: FillTemplate-Talk
Categories: Layout

Questions answered by this recipe

  • I have many pages of a category and would like to present them using a layout template in such a way that in future, changing the template automatically updates every page using it.


(:FillTemplate <template page> <template section> <data source>:)


Download oct-filltemplate.phpΔ and copy it to your cookbook folder. Install by adding to config.php:



Custom markup (:FillTemplate:) combines layout information from a template page with content from a data page in order to showcase PmWiki content in optional and predefined forms.

The template page contains any number of sections (stored between PmWiki bookmarks). Each 'section' represents an optional 'view' of the data. For example, a template page might contain sections:

  • RowData - used when showing a summary of members of a collection
  • Thumbnail - used when only wanting a thumbnail complete with link to a destination
  • FullPage - used to display all possible detail for a particular member of the collection.

Template data substitute live content with keywords. Keywords are used in the format (_KEYWORD_). e.g. (_FirstName_), (_LastName_), etc.

When the template is being filled, the markup simply replaces (for instance) (_FirstName_) in the template with the data found in the provided Data Page between [[#FirstName]] and [[#FirstNameEnd]].

To see it in action, visit my 'Relationships/Friends' page at

Markup arguments:

  • <template page>
    • A path to the WikiPage that contains templated layout data for one or more sections. The template page stores layouts in sections which replace actual content with keywords.
  • <template section>
    • A name that refers to the subsection of a template page. For example, it could be 'RowData' (without quotes). A section of that name should of course exist in the template page using the format:
      [[#SectionName]] (section content goes here) [[#SectionNameEnd]]
  • <data source>
    • A path to the WikiPage that contains the data to replace template KEYWORDS.

Step by step tutorial

I'll walk you through creating a gallery for people, similar to what I have on my personal website (see above for the url). Substitute the GROUP and PAGE names according to your site setup.

1. Create a data source

Create a page called Main.AlexData (e.g.Main.AlexData?action=edit)

Inside it place the following text:

[[#SummaryText]]This is customised summary text for (_FirstName_) of the (_LastName_) variety ;)[[#SummaryTextEnd]]

Repeat this for other people as you desire.

2. Create a template

Create a page called Main.FriendsTemplate (e.g.Main.FriendsTemplate?action=edit)

Note: This page is never viewd directly, so what you type outside the bookmarks does not matter.

Inside it, type:

(:cellnr width=5% :)
%newwin%[[(_ThumbImg_) -> (_ThumbTarget_)]]
(:cell style='padding:3px; border-top: #2F6FA2 solid 1px;' bgcolor=#fcfafc:)
'+'''(_FirstName_) (_LastName_)'''+'[[<<]]

3. Finally, create a display page

This is the page which will showcase your data, using the templates to apply the predefined layout.

Create a page called Main.Friends (e.g.Main.Friends?action=edit)

Inside it, place the following:

! My friends
(:table width='90%' align=center:)
(:FillTemplate Main.FriendsTemplate TableRow Main.AlexData:)
(:FillTemplate Main.FriendsTemplate TableRow Main.MarcData:)

That's it. You should be able to use this information to make it do far more for you.


Release Notes

  • 2006.04.11 - 1.0rc: first released into the wild.

See Also

You may want to take a look at the Clipboard. It does template filling too (to get a field use (:paste clip id=FirstName:) ).



See discussion at FillTemplate-Talk

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.