phpBB API Documentation
Class

phpbb\template\context

class context

Stores variables assigned to template.

Methods

__construct()

clear()

Clears template data set.

true assign_var(string $varname, string $varval)

Assign a single scalar value to a single key.

true append_var(string $varname, string $varval)

Append text to the string value stored in a key.

mixed retrieve_var(string $varname)

Retreive a single scalar value from a single key.

array get_data_ref()

Returns a reference to template data array.

array get_root_ref()

Returns a reference to template root scope.

true assign_block_vars(string $blockname, array $vararray)

Assign key variable pairs from an array to a specified block

true assign_block_vars_array(string $blockname, array $block_vars_array)

Assign key variable pairs from an array to a whole specified block loop

array retrieve_block_vars(string $blockname, array $vararray)

Retrieve key variable pairs from the specified block

mixed find_key_index($blockname, $key)

Find the index for a specified key in the innermost specified block

bool alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')

Change already assigned key variable pair (one-dimensional - single loop entry)

true destroy_block_vars(string $blockname)

Reset/empty complete block

Details

at line 42
public __construct()

at line 50
public clear()

Clears template data set.

at line 66
public true assign_var(string $varname, string $varval)

Assign a single scalar value to a single key.

Value can be a string, an integer or a boolean.

Parameters

string $varname Variable name
string $varval Value to assign to variable

Return Value

true

at line 82
public true append_var(string $varname, string $varval)

Append text to the string value stored in a key.

Text is appended using the string concatenation operator (.).

Parameters

string $varname Variable name
string $varval Value to append to variable

Return Value

true

at line 95
public mixed retrieve_var(string $varname)

Retreive a single scalar value from a single key.

Parameters

string $varname Variable name

Return Value

mixed Variable value, or null if not set

at line 110
public array get_data_ref()

Returns a reference to template data array.

This function is public so that template renderer may invoke it. Users should alter template variables via functions in \phpbb\template\template.

Note: modifying returned array will affect data stored in the context.

Return Value

array template data

at line 177
public array get_root_ref()

Returns a reference to template root scope.

This function is public so that template renderer may invoke it. Users should not need to invoke this function.

Note: modifying returned array will affect data stored in the context.

Return Value

array template data

at line 190
public true assign_block_vars(string $blockname, array $vararray)

Assign key variable pairs from an array to a specified block

Parameters

string $blockname Name of block to assign $vararray to
array $vararray A hash of variable name => value pairs

Return Value

true

at line 247
public true assign_block_vars_array(string $blockname, array $block_vars_array)

Assign key variable pairs from an array to a whole specified block loop

Parameters

string $blockname Name of block to assign $blockvarsarray to
array $block_vars_array An array of hashes of variable name => value pairs

Return Value

true

at line 264
public array retrieve_block_vars(string $blockname, array $vararray)

Retrieve key variable pairs from the specified block

Parameters

string $blockname Name of block to retrieve $vararray from
array $vararray An array of variable names, empty array retrieves all vars

Return Value

array of hashes with variable name as key and retrieved value or null as value

at line 334
public mixed find_key_index($blockname, $key)

Find the index for a specified key in the innermost specified block

Parameters

$blockname
$key

Return Value

mixed false if not found, index position otherwise; be sure to test with ===

at line 430
public bool alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')

Change already assigned key variable pair (one-dimensional - single loop entry)

An example of how to use this function: {@example alterblockarray.php}

Parameters

$blockname
array $vararray
$key
$mode

Return Value

bool false on error, true on success

at line 607
public true destroy_block_vars(string $blockname)

Reset/empty complete block

Parameters

string $blockname Name of block to destroy

Return Value

true