Template
in package
Template engine
Tags
Table of Contents
- $cols : int
- Number of columns for grid display
- $items : array<string|int, mixed>
- Array of data
- $num : int
- Variable for line break (Grid)
- $src : string
- Name of the currently used template including the folder where the template is stored Starting from DOCUMENT_ROOT, e.g., skin/default/
- $skin : string
- Template data
- add() : static
- Sets the template variables This function replaces all variables with the provided values in the template immediately
- create() : static
- Loads a template It checks the module's file first, if not found, it uses the owner's file
- createFromFile() : static
- Loads a template from a file
- createFromHTML() : static
- Creates a template from HTML
- get() : string
- Returns the directory of the template starting from DOCUMENT_ROOT
- hasItem() : bool
- Checks if data has been added to the template
- init() : mixed
- Sets the template to be used
- insertHTML() : static
- Inserts HTML into the template directly Used to insert HTML between items
- isEmpty() : bool
- Checks if the Template file is empty
- load() : string
- Loads a template It checks the module's file first, if not found, it uses the owner's file If not found, it returns an empty string
- pregReplace() : string
- Executes the preg_replace function
- render() : string
- Returns the rendered HTML
Properties
$cols
Number of columns for grid display
protected
int
$cols
= 0
$items
Array of data
protected
array<string|int, mixed>
$items
$num
Variable for line break (Grid)
protected
int
$num
$src
Name of the currently used template including the folder where the template is stored Starting from DOCUMENT_ROOT, e.g., skin/default/
protected
static string
$src
$skin
Template data
private
string
$skin
Methods
add()
Sets the template variables This function replaces all variables with the provided values in the template immediately
public
add(array<string|int, mixed> $array) : static
Parameters
- $array : array<string|int, mixed>
-
An array of variable names and their corresponding values to be replaced in the template Format: array(key1=>val1,key2=>val2)
Return values
static —create()
Loads a template It checks the module's file first, if not found, it uses the owner's file
public
static create(string $owner, string $module, string $name) : static
Parameters
- $owner : string
-
The name of the installed module
- $module : string
-
The name of the module
- $name : string
-
The name of the template without the file extension
Tags
Return values
static —createFromFile()
Loads a template from a file
public
static createFromFile(string $filename) : static
Parameters
- $filename : string
-
The filename
Tags
Return values
static —createFromHTML()
Creates a template from HTML
public
static createFromHTML(string $html) : static
Parameters
- $html : string
-
The HTML code
Return values
static —get()
Returns the directory of the template starting from DOCUMENT_ROOT
public
static get() : string
Return values
string —hasItem()
Checks if data has been added to the template
public
hasItem() : bool
Return values
bool —Returns true if the add function has been called before, false otherwise
init()
Sets the template to be used
public
static init(string $skin) : mixed
Parameters
- $skin : string
-
The directory of the template starting from DOCUMENT_ROOT without a trailing slash, e.g., skin/default
Return values
mixed —insertHTML()
Inserts HTML into the template directly Used to insert HTML between items
public
insertHTML(string $html) : static
Parameters
- $html : string
-
The HTML code
Return values
static —isEmpty()
Checks if the Template file is empty
public
isEmpty() : bool
Return values
bool —Returns true if the Template file is empty or not found, false otherwise
load()
Loads a template It checks the module's file first, if not found, it uses the owner's file If not found, it returns an empty string
public
static load(string $owner, string $module, string $name) : string
Parameters
- $owner : string
-
The name of the installed module
- $module : string
-
The name of the registered module
- $name : string
-
The name of the template without the file extension
Return values
string —pregReplace()
Executes the preg_replace function
public
static pregReplace(array<string|int, mixed> $patt, array<string|int, mixed> $replace, string $skin) : string
Parameters
- $patt : array<string|int, mixed>
-
The keys in the template
- $replace : array<string|int, mixed>
-
The text to replace the keys
- $skin : string
-
The template
Tags
Return values
string —render()
Returns the rendered HTML
public
render() : string