wiki:Docs/TagReference
Last modified 8 years ago Last modified on 08/20/06 20:11:57

WikiInclude(Includes/Header)?

patTemplate tag reference

All patTemplate tags have to be placed in the patTemplate namespace and thus prefixed with patTemplate, as long as you did not change the namespace. So every tag must look like in the following example:

<patTemplate:tmpl name="foo">
  some content
</patTemplate:tmpl>

All tags and attribute names are case-insensitive.

The "tmpl" tag

The <patTemplate:tmpl/> tag is the main patTemplate tag. It is used to mark a block in a template which can be accessed from your PHP script.

Attributes

Required attributes are:

  • name : the unique name of the template

Optional attributes are:

  • addsystemvars : Flag to indicate, whether system variables should be added to the template. Possible values are boolean, integer or off
  • autoclear : Flag to indicate, whether the template should be cleared when parsed more than once.
  • autoload : Flag to indicate, whether the external template should automatically be loaded or only when it is requested. May only be used, if the src attribute has been set.
  • conditionVar : name of the variable that will be tested in the sub-templates (only for type="condition")
  • defaultModifier : name of the default variable modifier that will be applied to all variables inside the template.
  • loop : Number of minimum repetitions, regardless whether there is enough data assigned to the variables
  • limit : Restricts the number of repetitions. The syntax is identical to MySQL's LIMIT statement.
  • maxloop : Restricts the numer of maximum repetitions for the template. If there is more data available, the parent template will be repeated instead.
  • modulo : Modulo to use. Only available when type="modulo".
  • outputfilter : Name of an Output filter that will be applied to this template.
  • parse : Flag to indicate, whether the external file referenced in src contains patTemplate tags (yes) or not (no) (may only used in conjuction with src)
  • reader : Name of the reader to use for parsing the external template. May only be used with src.
  • relative : Flag to indicate, whether the filename in src is relative to the current file (yes) or not (no) (may only used in conjuction with src)
  • requiredvars : Comma separated list of variables that must be set in order for the template to be displayed. May only be used in conjunction with type="simpleCondition".
  • rowoffset : starting number for the {PAT_ROW_VAR} variable.
  • src : File that contains the content for this template (if it is external)
  • type : The type of the template (standard, condition, simpleCondition), OddEven or modulo
  • unusedvars : Behaviour that will be applied to all variables that have no value assigned. Possible values are strip, ignore, comment or nbsp
  • useglobals : Flag to indicate whether global variables should be checked in conditions. May only used when type is set to condition or simpleCondition
  • varscope : Comma-separated list of other templates from which the variables will be imported
  • visibility : Visibility of the template. Possible values are visible or hidden.
  • whitespace : Whitespace treatment that will be applied to the template. Possible values are keep or trim

Example

<patTemplate:tmpl name="foo">
  some content
</patTemplate:tmpl>

The "sub" tag

The <patTemplate:sub/> tag is used inside a <patTemplate:tmpl/> tag, if its type attribute is set to condition, OddEven, or modulo. It is used to define content that depends on different conditions.

Attributes

Required attributes are:

  • condition : the condition for this sub-template. You may use any value or one of these special conditions:
    • __odd : current row is an odd row (only for type="OddEven")
    • __even : current row is an odd row (only for type="OddEven")
    • __empty : the tested variable is empty
    • __first : the current repetition is the first repetition
    • __last : the current repetition is the last repetition
    • __single : the template is not repeated
    • __default : none of the other conditions matched

Optional attributes are:

The <patTemplate:sub/> tag does not suppport optional attributes.

Example

<patTemplate:tmpl name="foo" type="OddEven">
  <patTemplate:sub condition="__odd">
    This is an odd row.<br/>
  </patTemplate:sub>
  <patTemplate:sub condition="__even">
    This is an odd row.<br/>
  </patTemplate:sub>
</patTemplate:tmpl>

The "link" tag

The link tag works like a symlink on a UNIX system, it only references the content of a different template without creating an actual copy of it.

Attributes

Required attributes are:

  • src : name of the referenced template

Optional attributes are:

The <patTemplate:link/> tag does not suppport optional attributes.

The <patTemplate:link/> tag is always empty.

Example

<patTemplate:tmpl name="page">
  <patTemplate:tmpl name="foo">
    My name is {REALNAME}.
  </patTemplate:tmpl>
  <patTemplate:link src="foo"/>
</patTemplate:tmpl>

The "var" tag

The <patTemplate:var/> tag can be used to insert a variable in a template. It adds some extra functionality to the plain variables that are inserted via curly braces.

Attributes

Required attributes are:

  • name : the name of the variable

Optional attributes are:

  • copyFrom : Name of the variable from which the value should be copied.
  • default : The default value, if the variable is not assigned a value from PHP. Starting with patTemplate 3.1.0a3, this may also be a PHP function.
  • hidden : Flag to indicate, whether the variable should be hidden (yes) or shown (no) at this place in the template.
  • modifier : The variable modifier which should be applied. May either be a PHP function or a modifier class. Starting with patTemplate 3.1.0a3, you may pass a comma-separated list of variable modifiers.
  • modifiertype : Type of the modifier. Possible values are auto, php and custom

Example

<patTemplate:tmpl name="foo">
  This is a simple variable: <patTemplate:var name="simple"/>, it is identical to using {SIMPLE}.
  This is a variable with a default value: <patTemplate:var name="foo" default="bar"/>.
  This is a variable which is copied from another variable: <patTemplate:var name="bar" copyFrom="foo" modifier="ucfirst/>.
  This is a variable with a default value created by a PHP function: <patTemplate:var name="timestamp" default="time()"/>.
</patTemplate:tmpl>

You should also take a look at the sections describing default values for variables and variable modifiers.

The "comment" tag

The <patTemplate:comment/> tag can be used remove any text from the output. It is similar to an HTML comment, but will not even be outputted.

Attributes

The <patTemplate:comment/> tag does not support any attributes.

Example

<patTemplate:tmpl name="foo">
  This is sent to the browser.
  <patTemplate:comment>
    This is not sent to the browser.
  </patTemplate:comment>
</patTemplate:tmpl>

Creating new tags

patTemplate allows you to create new tags and implement PHP code to handle them. See the developer documentation for more information.