|
|
Home patTemplate Preface patTemplate Overview |
| patTemplate Overview |
|
|
|
TagsThere are five xml tags available in patTemplate that form the building blocks for the templating engine:
Tag NamespacesAll patTemplate tags must include a namespace which is used to distinguish the patTemplate XML markup tags from regular HTML, xHTML and other XML tags. The default namespace is patTemplate but you my change this as desired by calling the setNamespace method. <?php $tmpl =& new patTemplate(); // change the namespace to 'cms' $tmpl->setNamespace( 'cms' ); ?> <!-- using your custom namespace --><!-- using your custom namespace --> This is a test of my content management system. Template TypesTemplates are parts of html pages, which can be displayed by the template engine. To identify a certain part of the page as a template, patTemplate uses XML tags to assign a template a unique name and a various attributes (see patTemplate Tags and attributes for a list of all tags and attributes). When parsing a template, the parser divides the page in several chunks and treats them as separate templates. By using patTemplate's API you can hide, display or repeat a certain template. A template can contain as many other templates as you like. Templates can be of these types (defined by using the type="..." attribute):
Template VariablespatTemplate supports variables similar to programming languages. There can be local variables (assigned by the addVar method) and global variables (assigned by the addGlobalVar method). Global variables can only be scalar variables (strings, integers,...) and local variables can also be arrays. If you assign an array to a variable, the template where you assigned the variable will be repeated. If a condition template uses the useglobals="yes" attribute global variables will be used if no local variables are set. Variables have to be written in uppercase and may only contain chars, numbers or the underscore (_). Variables are always enclosed in curly brackets, for example, {FOO}. Variables will be replaced with their values when parsing a template. There are several predefined system variables that are available when you set the addsystemvars attribute.
Tag AttributesTemplates can have different attributes, the can be set using setAttribute or by placing the attributes in the Tags. See patTemplate Tags and attributes for details. ExamplesThe downloadable package of patTemplate contains several examples (currently only in German), which explain the basic functions. |
|
| Last Updated ( Thursday, 30 December 2004 ) |
| < Prev |
|---|





