SourceForge.net Logo
August 24, 2009
GPL
ProWikiCenter
Variable /
Template Insert Pass List


TemplateInsertPassList takes a ValueList and defines passes through the TemplateText which insert all the dynamic parts when a wiki page is rendered. The default value is "Insert" which means that all dynamic elements are inserted in a single pass which has the name "Insert", which in turn means that commands in the TemplateText that have the form {Insert:something} are processed.

If you define

this means that you have three passes:

  1. pass "PreInsert" working on commands {PreInsert:something}
  2. pass "Insert" working on commands {Insert:something}
  3. pass "PostInsert" working on commands {PostInsert:something}
Note that you can give arbitrary names to passes but one of it should be named "Insert" because you otherwise couldn't use standard templates without converting their insertion commands.

Why could someone want to have additional passes?

Example 1: PreInsert is used to implement ChangeableSideBar.

Example 2: PostInsert is used in some wikis to post-process text that comes from external scripts that are called during the "Insert" pass. The external script could e. g. output a text "{PostInsert:UserName}" which would in turn be processed by ProWikiScript to insert the actual user name. This is pretty advanced stuff.

Example

AndriusKulikauskas August 24, 2009 7:36 CET Here's a script that I wrote for my template at http://www.worknets.org and subwikis which include http://www.globalvillages.info and http://www.earthtreasury.org I have a "Write on this page" link and I need it to point to the relevant edit page. So I wrote a Perl script in my bin directory:

#!/usr/bin/perl

# Create the correct link to the edit page
# Remove the topmost level if we are not in worknets.org

$domain = @ARGV[0];  # {Insert:DomainUrl}
$pagecur = @ARGV[1];  # {Insert:PageCur}

@pagenamearray = split(/\//,$pagecur);
$section = @pagenamearray[0];

if ($domain ne "http://www.worknets.org") {
    $pagecur = substr($pagecur,length($section)+1);
}

$editlink = $domain."/wiki.cgi?action=edit&id=".$pagecur;

print $editlink;

and in my template I call it in the line:

<a href="{Insert:program.linkforeditpage {PreInsert:DomainUrl} {PreInsert:PageCur}}">Write on this page</a>

where the PreInsert writes in the arguments of the script so they are there when the script is called.


FolderWikiFeatures FolderLayout FolderTemplate