Include is used to including one template into another.
Table 2.6. Include: parameters
| Name | Type | Required? | Description |
|---|---|---|---|
| file | Expression | Yes | The template file we want to include. |
| default | Expression | No | The default file to include, if the template pointed by the file parameter doesn't exist. |
| assign | ID | No | If specified, the template output is captured to the specified variable. |
When using XML-style parameters, you may specify additional parameters for the template. Their values will be put as template variables. Here we have a sample template to include:
<p>Mr {@name} has already paid us ${@amount}.</p>Now we include it two times, with different data:
Example 2.54. Including and template parameters
{* This will display "Mr John Smith has already paid us $150.30" *}
{include file="`sample.tpl`" name="`John Smith`" amount="150.3"}
{* This will display "Mr Adam Brown has already paid us $535.70" *}
{include file="`sample.tpl`" name="`Adam Brown`" amount="535.7"}While specifying the file names to include, remember about OPT syntax. The file name must be enclosed in some sort of quotes:
{include=`file.tpl`}or
{include file="`file.tpl`"}In the second example, the double quotes are a part of the parameter syntax. The reversed quotes are a part of the expression and enclose the file name in both examples.