|
Cookbook /
FillTemplateSummary: 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
Categories: Layout
Questions answered by this recipe
Usage
InstallingDownload oct-filltemplate.phpΔ and copy it to your cookbook folder. Install by adding to config.php:
DescriptionCustom 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:
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 http://www.octocias.com. Markup arguments:
Step by step tutorialI'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 sourceCreate a page called Main.AlexData (e.g.Main.AlexData?action=edit) Inside it place the following text: [[#WebDir]]UrlToData:friends/alex[[#WebDirEnd]] [[#FirstName]]Alex[[#FirstNameEnd]] [[#LastName]]Prykhodko[[#LastNameEnd]] [[#SummaryText]]This is customised summary text for (_FirstName_) of the (_LastName_) variety ;)[[#SummaryTextEnd]] [[#ThumbTarget]]http://[[#ThumbTargetEnd]] [[#ThumbImg]](_WebDir_)/thumbnail.png[[#ThumbImgEnd]] Repeat this for other people as you desire. 2. Create a templateCreate 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: [[#TableRow]] (:cellnr width=5% :) %newwin%[[(_ThumbImg_) -> (_ThumbTarget_)]] (:cell style='padding:3px; border-top: #2F6FA2 solid 1px;' bgcolor=#fcfafc:) '+'''(_FirstName_) (_LastName_)'''+'[[<<]] (_SummaryText_) [[#TableRowEnd]] 3. Finally, create a display pageThis 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:) . . . (:tableend:) That's it. You should be able to use this information to make it do far more for you. NotesRelease Notes
CommentsCongratulations! Very nice recipe and documentation. It looks like it has alot of potential.
See AlsoYou may want to take a look at the Clipboard. It does template filling too (to get a field use Contributors |