pad

PAD Tag Types Reference

This document provides a complete reference for all PAD tag types.

Overview

Every PAD tag has a type that determines how it’s processed. Types are automatically detected based on the tag name, or can be explicitly specified using the type:name syntax.

Type Syntax

Automatic Detection

{tagName}

PAD automatically detects the type based on what tagName matches.

Explicit Type

{type:name}

Explicitly specify the type for disambiguation.

Examples:

{users}              ← Auto-detected as 'select' type (if declared in $padSelect)
{select:users}       ← Explicitly specified as select type
{field:username}     ← Explicitly field type
{php:strtoupper 'abc'} ← Explicitly PHP function type

Type Detection Order

When no explicit type is given, PAD checks in this order (see padTypeTag() and padTypeCommon() in PAD/lib/type.php):

  1. app - Application tag in the app’s _tags/ directories
  2. common - Tag in the shared _common app
  3. pad - Built-in PAD tag in PAD/tags/
  4. pull - Sequence store value
  5. bool - Boolean store
  6. content - Content store
  7. select - Declared select table
  8. data - Data store
  9. include - Application include file
  10. property - Tag property
  11. field - Field of the current data row
  12. array - Array value
  13. parm - Parameter value
  14. level - Array field of an enclosing row
  15. constant - PHP constant
  16. local - Local data file
  17. script - External script
  18. php - PHP function - one that is also a pipe function (trim, date, substr …) runs as the pipe function
  19. sequence - Sequence type
  20. action - Sequence action
  21. function - PAD function (fallback)

A field or array that exists only as a request value - a GET, POST or cookie value the page’s PHP (its configuration, _inits.php, the page, _exits.php) does not name, held by no row - comes after all of them: a visitor’s ?prime=x never takes the place of the sequence, constant, _data file or function the template names, and is the field only when the template means nothing else by the name.


Tag Types

app

Loads application-specific tags from _tags/ in the page’s directory or a parent’s, up to the application root.

{myCustomTag}
{app:myCustomTag}

Resolution: Checks padAppTagCheck() for tag in application directory.

Files loaded:

Use case: Application-specific custom tags.


pad

Loads built-in PAD tags from the PAD/tags/ directory.

{if}
{pad:if}

Resolution: PAD/tags/{tagName}.php or .pad

Files loaded:

Use case: Core PAD framework tags.


common

Loads shared tags from the apps/_common/ application.

{padFrame}
{common:padFrame}

Resolution: padCommonCheck() - checked after app, before pad, so a common tag overrides a built-in of the same name but not an app-local one. Can be disabled per app with $padCommon = FALSE.

Use case: Tags shared by all applications - the frame of the PAD applications, {example}, {demo}, {table}.


data

Retrieves data from the data store ($padDataStore).

{data:myData}
{myData}  ← If myData exists in data store

Resolution: $padDataStore[$tagName]

Options:

Example:

{users toData="activeUsers"}
{data:activeUsers}

content

Retrieves content from the content store ($padContentStore).

{content:header}

Resolution: $padContentStore[$tagName]

Example:

{header toContent="savedHeader"}
{content:savedHeader}

bool

Retrieves boolean values from the boolean store ($padBoolStore).

{bool:isAdmin}

Resolution: $padBoolStore[$tagName]

Returns: The stored boolean value.

Example:

{checkAdmin toBool="isAdmin"}
{if bool:isAdmin}...{/if}

field

Retrieves field values from the current data context.

{field:username}
{$username}  ← Shorthand for field

Resolution: padFieldValue($tagName)

Returns: Field value, or NULL if field is null.

Example:

{users}{field:email}{/users}
{users}{$email}{/users}  ← Equivalent

property

Retrieves tag properties from parent tags.

{property:current}
{&current}  ← Shorthand for property

Resolution: padTagValue($tagName)

Supports: Parameter prefixing with $padParm.

Example:

{users}{&current}{/users}

array

Retrieves array values by name.

{array:myArray}

Resolution: padArrayValue($tagName)

Use case: Access named arrays in the current context.


parm

Retrieves a parameter or option of the tag directly around it - an {if} or {case} in between is skipped, any other tag is not: inside {users mode="fast"}{orders} the {orders} is asked, and has no mode.

{users mode="fast"}{parm:mode}{/users}

Resolution: padOptValue($tagName, 1)


level

Retrieves an array field of an enclosing row - the nearest level outward that holds one - and iterates it.

{orders}{level:lines}{$product}{/level:lines}{/orders}

Resolution: padGetLevelArray($tagName)

Use case: Walk a nested array of the row being rendered. A {tag $name = value} level variable is not what it reads.


constant

Retrieves PHP constants by name.

{constant:PHP_VERSION}
{constant:APP}

Resolution: constant($tagName)

Returns: The value of the PHP constant.

Example:

{constant:PHP_EOL}
{constant:TRUE}

local

Loads local data files with automatic type detection.

{local:users.json}
{myfile}            ← _data/myfile.csv, the extension found for it

Resolution: padDataFileName($tagName) - a file directly in _data/ (a name holds no /), with its extension or with the first of .xml, .json, .yaml, .csv, .php, .curl, .sql that exists; a bare tag is written without the extension.

Supported formats:

Options:

Example:

{local:settings.json}
{local:data.csv name='myData', type='csv'}

include

Includes content from application include files.

{include:header}

Resolution: padAppIncludeCheck($tagName)

Returns: Included file content.


select

Queries database tables declared in the PAD Select subsystem.

{select:users}
{users}  ← If 'users' is declared in $padSelect

Resolution: isset($padSelect[$tagName]) - tables are declared in the app’s _lib/select.php via $padSelect (and relations via $padRelations).

Returns: Query results as iterable data; nested select tags join automatically through $padRelations.

Example:

{users $id=5}
  {$username}
{/users}

See DATABASE.md for the full Select subsystem reference.


function

Executes PAD functions as tags.

{function:trim}content{/function:trim}
{trim}content{/trim}

Resolution: padFunctionAsTag($tagName)

Behavior:

Example:

{upper}hello{/upper}  →  HELLO
{replace 'a', 'b'}aaa{/replace}  →  bbb

php

Calls PHP built-in functions directly.

{php:strtoupper 'hello'}
{php:date 'Y-m-d'}

Resolution: function_exists($tagName)

Implementation: call_user_func_array($tagName, $parameters)

Example:

{php:strlen 'hello'}  →  5
{php:array_sum [1,2,3]}  →  6

script

Executes external shell scripts.

{script:myscript}
{script:processor 'arg1', 'arg2'}

Resolution: padScriptCheck($tagName) - _scripts/<name>, or _scripts/<name>.<ext>, from the page’s directory up to the application root.

Features:

Returns: Script output (stdout).


Sequence Types

These types integrate with the PAD sequence subsystem.

sequence

Accesses sequence type definitions.

{sequence:fibonacci}

Resolution: file_exists(PT . $tagName)

Implementation: Delegates to PQ/start/types/sequence.php.


action

Executes sequence actions.

{action:sum}
{mySequence:sum}

Resolution: file_exists(PQ/actions/types/$tagName.php)

Implementation: Delegates to PQ/start/types/action.php.


pull

Retrieves values from the sequence store.

{pull:mySequence}
{mySequence}  ← If exists in pqStore

Resolution: isset($pqStore[$tagName])

Implementation: Delegates to PQ/start/types/pull.php.


flag

Turns each value of a sequence into 1 or 0: whether it belongs to the named sequence type.

{flag:prime}
{mySeq:flag even}

Resolution: padTypeSeq() - a sequence type or a stored sequence.

Implementation: Delegates to PQ/start/types/flag.php. (In an expression, flag:name reads the bool store instead.)


make

Creates new sequence values.

{make:fibonacci}
{fibonacci:make}

Resolution: Sequence exists + make type available.

Implementation: Delegates to PQ/start/types/make.php.


keep

Keeps only the values the named sequence type accepts; nothing is stored.

{keep:mySequence even}

Implementation: Delegates to PQ/start/types/keep.php.


remove

Drops the values the named sequence type accepts; no store is dropped.

{remove:mySequence even}

Implementation: Delegates to PQ/start/types/remove.php.


Type Summary Table

Type Source Description
app App _tags/ Application-specific tags
common apps/_common/ Shared tags
pad PAD/tags/ Built-in PAD tags
data $padDataStore Stored data arrays
content $padContentStore Stored content strings
bool $padBoolStore Boolean flags
field Current data Field values
property Parent tag Tag properties
array Arrays Named arrays
parm Enclosing tag Parameter/option value
level Enclosing rows Nested array field
constant PHP PHP constants
local Files Local data files
include APP Include files
select $padSelect Declared select tables
function PAD/functions/ PAD functions
php PHP PHP functions
script Scripts Shell scripts
sequence PQ Sequence types
action PQ Sequence actions
pull pqStore Sequence values
flag PQ Membership flags, 1 or 0
make PQ Sequence creation
keep PQ Filter: keep the matches
remove PQ Filter: drop the matches

Type Handler Files

Each type has a corresponding handler in PAD/types/:

types/
├── action.php      → Sequence action
├── app.php         → Application tag
├── array.php       → Array value
├── bool.php        → Boolean store
├── common.php      → Shared _common tag
├── constant.php    → PHP constant
├── content.php     → Content store
├── data.php        → Data store
├── field.php       → Field value
├── flag.php        → Sequence membership flags
├── function.php    → PAD function
├── include.php     → Include file
├── keep.php        → Sequence keep
├── level.php       → Array field of an enclosing row
├── local.php       → Local file
├── make.php        → Sequence make
├── pad.php         → PAD tag
├── parm.php        → Tag parameter
├── php.php         → PHP function
├── property.php    → Tag property
├── pull.php        → Sequence pull
├── remove.php      → Sequence remove
├── script.php      → Shell script
├── select.php      → Select table query
├── sequence.php    → Sequence type
└── _go/
    ├── local.php   → Local file processing
    └── tag.php     → Tag file loading

Examples

Mixed Type Usage

{users where='$active eq 1', toData='activeUsers'}

{if data:activeUsers}
  <h2>Active Users ({php:count data:activeUsers})</h2>
  {data:activeUsers}
    <div>{field:name} - {field:email}</div>
  {/data:activeUsers}
{else}
  <p>No active users</p>
{/if}

<footer>{constant:PHP_VERSION}</footer>

Explicit Type Disambiguation

{-- 'date' could be a field, function, or PHP function --}
{field:date}          ← Get date field value
{function:date}       ← Use PAD date function
{php:date 'Y-m-d'}    ← Use PHP date function

Sequence Operations

{fibonacci:make rows=10, push='fib'}{/fibonacci:make}
{fib:sum}{$sequence}{/fib:sum}
{pull:fib}{$sequence} {/pull:fib}
{fib:remove even}{$sequence} {/fib:remove}