Template Markup

Any content of a Fox template will become part of the new page entry. PmWiki page variables and page text variables are allowed and not rendered/evaluated, but posted unaltered.
Special replacement variables are used to mark where content from input fields are placed, and for rendering/evaluation of page variables and page text variables, and markup expressions:

{$$name}
is replaced by the value of the form input field named name
{$$name[]}
is replaced by the array values of the form input fields named name[]
{=$PageVar}, {PageName=$PageVar}
is replaced with the value of page variable named PageVar (from page PageName). Note that PageName can be a replacement variable.
{=$:ptvname}, {PageName=$:ptvname}
is replaced with the value of page text variable (PTV) named ptvname (from page PageName). Note that PageName can be a replacement variable.
{$$(timestamp)}
is replaced with the Unix timestamp of the time of form submission.
{$$(expr ... )}
Markup expressions with this syntax (two $ dollar signs after the initial curly bracket ) are evaluated when the template gets processed. Such template markup expressions can be nested (with use of round brackets, not curly brackets) and can contain replacement variables.
{$$(ftime 'format' 'when')}
is replaced with a formatted date or time string, using MarkupExpressions#ftime (this utilises the PHP strftime function). The {$$(strftime:format)} markup is deprecated. Example for a timestamp: {$$(ftime "%A %d %B %Y %H:%M:%S")}
{$$(date:format)}
is replaced with a formatted date or time string, according to the PHP date function. Example: {$$(date:d.m.Y - H:i)}
\n
is converted into a new line.
{$$foxgrouptitle}
this is created early and takes the value from a foxgroup field or parameter. It is for use where special characters and spaces may want to be preserved, as {$$foxgroup} will be replaced by a sanitised WikiWord valid for full pagenames. Use for instance to create a target group link: [[{$foxgroup}/| {$$foxgrouptitle}]]

To post replacement variables without them being replaced by a value, in order for instance to post a fox form defined as a template, use {$$$name} instead of {$$name} etc. To post replacement variables for page variables and PTVs, without them being evaluated, use {PageName=$$var} or {PageName=$$:ptv} instead of {PageName=$var} or {PageName=$:ptv} etc., i.e. add a $ symbol, which gets stripped on form submission.

delete links and buttons template markup

Install Attach:Wiki/FoxDelete/foxdelete.php Δ and use the following template markup to generate delete links and buttons for deleting single lines or ranges.

{[foxdelline]}
is replaced by a delete link which can be used to delete the line it is part of.
{[foxdelline button]}
is replaced by a delete button for deleting a single line, as the link above.
{[foxdelrange]}
is replaced by a delete link which can be used to delete a range of lines, marked with special #foxbegin# and #foxend# markers. Any lines between these invisible markers, including a range delte link or button, will be deleted by clicking the link or button
{[foxdelrange button]}
is replaced by a delete button for deleting a range of lines, as the link above.
Delete link label and tooltip
a custom delete label for link or button can be specified inside the markup like for instance:
{[foxdelrange 'Delete Post']} : Delete Post will be the label for new delete links.
{[foxdelrange label='Delete Post' tooltip='delete section: abc']}: delete link with added tooltip.

Notes to function FoxTemplateEngine

Variable substitutions of contents of a Fox template file.

 Takes:
   $pagename    - the current pagename (for inserting in links)
   $template    - a string holding the template to interpret
   $fx          - an array of fields to use to interpret the template
   $tg        - an array of parameters associated to the target page  
   $linekeyseed - optional seed for the random key used to identify
                  parts of the output for later delete actions.
   $caller      - name of function which calls

 Returns:
   Returns a string containing the expanded template.

 Processing:
   Special template markup is searched for in the template string,
   and replaced, in order, as follows. Note that processing continues
   until no replacements are made, or a global iteration count is
   exceeded.

   (:.....:) and {(....)}
     if $EnablePostDirectives isn't set, then directives and markup 
     expressions are escaped so that they appear as-is in the given 
     text, without being executed or evalued. 
     FoxDefuseMarkup is called to do this work.

   {$$field}
     When the value of the field 'field' is a single string, it is
     substituted in place. When the field is an array of values, then
     the value substituted is the same as if the replaced string had
     been {$$field[{$$foxtindex}]}. The value of {$$foxtindex} is the
     index of the current template being expanded, in the array of
     templates, starting with zero.

   {$$field[num]}
     When the value of the field 'field' is an array, and 'num' is a
     number, then the element with index 'num' in the array is
     substituted. If the field is not an array, or if there is no
     such element, then the markup is simply removed. Note that when
     'num' is non-numeric, the markup is left unsubstituted, but do
     not rely on that, as further extensions may make use of
     non-numeric array indexes.

   {$$(function args...)}
     is replaced by the results of evaluating 'function' as if it
     were an ordinary Markup Expression (ie, as if it were the string
     '{(function args...)}' on a normal page). In order to provide
     backward compatibility, Fox.php adds a 'date' function to the
     list of valid markup extensions.

   {$$field[]}
     The existence of one or more special markups of this form cause
     a special processing mode to be entered. For each element in the
     longest array named by this form in the template, a duplicate of
     the template is produced. The first duplicate contains all
     values of the 0th element of the named arrays, the second
     duplicate contains the 1st elements and so on. Missing elements
     are treated as null strings. All of the duplicates are written
     to the target, in order. The template can be broken into
     multiple sections with {[foxsection]} markers, each such section
     being treated independantly in this manner.

   {$$$
     A final pass is made in which '{$$$' is replaced by '{$$'. No
     further expansion is done, even if this results in new valid
     field names. This provides a mechanism to add special template
     markup to a page, in order to create another template.

<< Input Validation | Index | Field Substitutions >>