This document provides a complete reference for all PAD tag properties.
Tag properties provide contextual information during template execution. They are accessed using the property@tag syntax:
{property@tagname}
Where tagname is the name of the iteration/loop context and property is the information you want to access.
{first@users}
{count@items}
{current@rows}
{if first@users}<ul>{/if}
{if last@users}</ul>{/if}
{even@rows ? class="even" : class="odd"}
Properties that indicate position within a loop iteration.
Returns TRUE if this is the first iteration.
{first@tagname}
Logic: $padOccur[$padIdx] == 1
Example:
{users}
{if first@users}<table><tr><th>Name</th></tr>{/if}
<tr><td>{$name}</td></tr>
{/users}
Returns TRUE if this is the last iteration.
{last@tagname}
Logic: $padKey[$padIdx] == array_key_last($padData[$padIdx])
Example:
{users}
<tr><td>{$name}</td></tr>
{if last@users}</table>{/if}
{/users}
Returns TRUE if this is NOT the first iteration.
{notFirst@tagname}
Logic: ! first@tagname
Example:
{items}
{if notFirst@items}, {/if}{$name}
{/items}
Output: item1, item2, item3
Returns TRUE if this is NOT the last iteration.
{notLast@tagname}
Logic: ! last@tagname
Example:
{items}
{$name}{if notLast@items}|{/if}
{/items}
Output: item1|item2|item3
Returns TRUE if this is either the first OR last iteration.
{border@tagname}
Logic: first@tagname OR last@tagname
Example:
{items}
<div {if border@items}class="highlight"{/if}>{$name}</div>
{/items}
Returns TRUE if this is neither first nor last (middle items only).
{middle@tagname}
Logic: NOT border@tagname (neither first nor last)
Example:
{items}
{if middle@items}<div class="middle">{$name}</div>{/if}
{/items}
Returns TRUE if the current occurrence number is even.
{even@tagname}
Logic: $padOccur[$padIdx] % 2 == 0
Example:
{rows}
<tr class="{even@rows ? even : odd}">{$data}</tr>
{/rows}
Returns TRUE if the current occurrence number is odd.
{odd@tagname}
Logic: NOT even@tagname
Example:
{rows}
<tr class="{odd@rows ? odd : even}">{$data}</tr>
{/rows}
Properties that provide numeric information about the iteration.
Returns the current occurrence number (1-based index).
{current@tagname}
Returns: $padOccur[$padIdx]
Example:
{users}
{current@users}. {$name}
{/users}
Output:
1. Alice
2. Bob
3. Charlie
Returns the total number of items.
{count@tagname}
Returns: max(count($padData[$padIdx]), $padOccur[$padIdx])
Example:
{users}
User {current@users} of {count@users}
{/users}
Returns the number of iterations remaining.
{remaining@tagname}
Returns: count($padData[$padIdx]) - $padOccur[$padIdx] (minimum 0)
Example:
{users}
{$name} ({remaining@users} more to go)
{/users}
Returns the number of completed iterations (current - 1).
{done@tagname}
Returns: $padOccur[$padIdx] - 1
Example:
{users}
Processed: {done@users}, Current: {$name}
{/users}
Properties that provide access to the current data context.
Returns the complete data array for the current level.
{data@tagname}
Returns: $padData[$padIdx]
Example:
{users}
{data@users toData="allUsers"}
{/users}
Returns the current array key.
{key@tagname}
Returns: $padKey[$padIdx]
Example:
{config}
{key@config}: {$value}
{/config}
Output:
host: localhost
port: 3306
user: admin
Returns an array of all keys with their values as iterable data.
{keys@tagname}
Returns: Array where each item has name (the key) and value
Example:
{data myArray}
{keys@myArray}
Key: {$name}, Value: {$value}
{/keys}
{/data}
Returns an array of field name/value pairs from the current record.
{fields@tagname}
Returns: Array where each item has name and value
Example:
{user}
<table>
{fields@user}
<tr><td>{$name}</td><td>{$value}</td></tr>
{/fields}
</table>
{/user}
Output:
<table>
<tr><td>id</td><td>1</td></tr>
<tr><td>name</td><td>Alice</td></tr>
<tr><td>email</td><td>alice@example.com</td></tr>
</table>
Returns the name of the first field in the current record.
{firstFieldName@tagname}
Returns: First key from $padCurrent[$padIdx]
Example:
{user}
Primary field: {firstFieldName@user}
{/user}
Returns the value of the first field in the current record.
{firstFieldValue@tagname}
Returns: First value from $padCurrent[$padIdx]
Example:
{user}
Primary value: {firstFieldValue@user}
{/user}
Properties that provide information about the current tag.
Returns the name of the current tag/level.
{name@tagname}
Returns: $padName[$padIdx]
Example:
{users}
Processing tag: {name@users}
{/users}
Output: Processing tag: users
Properties for accessing tag parameters and options.
Returns a specific named parameter value.
{parameter:paramName@tagname}
Returns: $padPrm[$padIdx][$parm] or NULL
Example:
{myTag sort="name" limit="10"}
Sort by: {parameter:sort@myTag}
Limit: {parameter:limit@myTag}
{/myTag}
Returns all parameters as an iterable array.
{parameters@tagname}
Returns: All parameters from $padPrm[$padIdx]
Example:
{myTag foo="1" bar="2"}
{parameters@myTag}
{$name} = {$value}
{/parameters}
{/myTag}
Returns a specific positional option value.
{option:1@tagname}
{option:2@tagname}
Returns: $padOpt[$padIdx][$parm] or NULL
Example:
{myTag arg1 arg2 arg3}
First: {option:1@myTag}
Second: {option:2@myTag}
{/myTag}
Returns all positional options as an iterable array.
{options@tagname}
Returns: All options from $padOpt[$padIdx] (excluding index 0)
Example:
{myTag opt1 opt2 opt3}
{options@myTag}
Option: {$value}
{/options}
{/myTag}
Properties for accessing level-scoped variables.
Returns a specific level-scoped variable.
{variable:varName@tagname}
Returns: $padSetLvl[$padIdx][$parm] or NULL
Example:
{users myVar="test"}
Variable: {variable:myVar@users}
{/users}
Returns all level-scoped variables as an iterable array.
{variables@tagname}
Returns: All variables from $padSetLvl[$padIdx]
Example:
{users a="1" b="2"}
{variables@users}
{$name}: {$value}
{/variables}
{/users}
| Property | Type | Description |
|---|---|---|
first@tag |
Boolean | Is first iteration |
last@tag |
Boolean | Is last iteration |
notFirst@tag |
Boolean | Is NOT first iteration |
notLast@tag |
Boolean | Is NOT last iteration |
border@tag |
Boolean | Is first OR last |
middle@tag |
Boolean | Is neither first nor last |
even@tag |
Boolean | Is even occurrence |
odd@tag |
Boolean | Is odd occurrence |
current@tag |
Number | Current occurrence (1-based) |
count@tag |
Number | Total item count |
remaining@tag |
Number | Items remaining |
done@tag |
Number | Items completed |
data@tag |
Array | Full data array |
key@tag |
Mixed | Current array key |
keys@tag |
Array | All keys with values |
fields@tag |
Array | Field name/value pairs |
firstFieldName@tag |
String | First field’s name |
firstFieldValue@tag |
Mixed | First field’s value |
name@tag |
String | Tag name |
parameter:x@tag |
Mixed | Named parameter |
parameters@tag |
Array | All parameters |
option:n@tag |
Mixed | Positional option |
options@tag |
Array | All options |
variable:x@tag |
Mixed | Level variable |
variables@tag |
Array | All variables |
{rows}
<tr class="{even@rows ? row-even : row-odd}">{$data}</tr>
{/rows}
{items}
{if first@items}<ul>{/if}
<li>{$name}</li>
{if last@items}</ul>{/if}
{/items}
{tags}
{$name}{if notLast@tags}, {/if}
{/tags}
{users}
<div>
{current@users} of {count@users}: {$name}
{if remaining@users}({remaining@users} remaining){/if}
</div>
{/users}
{record}
<dl>
{fields@record}
<dt>{$name}</dt>
<dd>{$value}</dd>
{/fields}
</dl>
{/record}
{customTag mode="advanced" debug="true"}
Mode: {parameter:mode@customTag}
Debug: {parameter:debug@customTag}
{/customTag}