Class template

Description

Base Template class.

Located in /includes/template.php (line 23)


	
			
Variable Summary
 mixed $cachepath
 mixed $filename
 mixed $files
 mixed $root
 mixed $_rootref
 mixed $_tpldata
Method Summary
 bool alter_block_array (string $blockname, array $vararray, [mixed $key = false], [string $mode = 'insert'])
 void assign_block_vars ( $blockname,  $vararray)
 void assign_display ( $handle, [ $template_var = ''], [ $return_content = true], [ $include_once = false])
 void assign_var ( $varname,  $varval)
 void assign_vars ( $vararray)
 void destroy ()
 void destroy_block_vars ( $blockname)
 void display ( $handle, [ $include_once = true])
 void set_custom_template ( $template_path,  $template_name)
 void set_filenames ( $filename_array)
 void set_template ()
 void _tpl_include ( $filename, [ $include = true])
 void _tpl_load ( &$handle)
Variables
mixed $cachepath = '' (line 36)
mixed $compiled_code = array() (line 44)
mixed $filename = array() (line 38)
mixed $files = array() (line 37)
mixed $files_inherit = array() (line 39)
mixed $files_template = array() (line 40)
mixed $inherit_root = '' (line 41)
mixed $root = '' (line 35)
mixed $_rootref (line 32)
mixed $_tpldata = array('.' => array(0 => array())) (line 31)

variable that holds all the data we'll be substituting into

the compiled templates. Takes form: --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value if it's a root-level variable, it'll be like this: --> $this->_tpldata[.][0][varname] == value

Methods
alter_block_array (line 507)

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

An example of how to use this function:

  1. <?php
  2.  
  3. // We assign a simple block for testing.
  4. for ($i 0$i 5$i++)
  5. {
  6.     $template->assign_block_vars('loop'array(
  7.         'KEY'        => 'Iteration number ' $i)
  8.     );
  9. }
  10.  
  11. // Our array we want to put into the already assigned loop.
  12. $vararray array(
  13.     'KEY'        => 'Iteration injection',
  14.     'OTHER_KEY'    => 'Other value',
  15. );
  16.  
  17. // Insert vararray at the beginning
  18. alter_block_array('loop'$vararray);
  19.  
  20. // Insert vararray at position 2
  21. alter_block_array('loop'$vararray2);
  22.  
  23. // Insert vararray at the position where the key 'KEY' has the value of 'value' 
  24. alter_block_array('loop'$vararrayarray('KEY' => 'Iteration number 4'));
  25.  
  26. // Insert vararray at first position
  27. alter_block_array('loop'$vararrayfalse);
  28.  
  29. // Insert vararray at last position (assign_block_vars equivalence)
  30. alter_block_array('loop'$vararraytrue)
  31.  
  32. // Change/Merge vararray with existing array at position 2
  33. alter_block_array('loop'$vararray2'change');
  34.  
  35. // Change/Merge vararray with existing array at the position where the key
  36. // 'KEY' has the value of 'value' 
  37. alter_block_array('loop'$vararrayarray('KEY' => 'Iteration number 4')'change');
  38.  
  39. // Change/Merge vararray with existing array at first position
  40. alter_block_array('loop'$vararrayfalse'change');
  41.  
  42. // Change/Merge vararray with existing array at last position
  43. alter_block_array('loop'$vararraytrue'change');
  44.  
  45. ?>

  • return: false on error, true on success
  • access: public
bool alter_block_array (string $blockname, array $vararray, [mixed $key = false], [string $mode = 'insert'])
  • string $blockname: the blockname, for example 'loop'
  • array $vararray: the var array to insert/add or merge
  • mixed $key:

    Key to search for

    array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]

    int: Position [the position to change or insert at directly given]

    If key is false the position is set to 0 If key is true the position is set to the last entry

  • string $mode:

    Mode to execute (valid modes are 'insert' and 'change')

    If insert, the vararray is inserted at the given position (position counting from zero). If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).

    Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)

assign_block_vars (line 416)

Assign key variable pairs from an array to a specified block

  • access: public
void assign_block_vars ( $blockname,  $vararray)
  • $blockname
  • $vararray
assign_display (line 197)

Display the handle and assign the output to a template variable or return the compiled result.

  • access: public
void assign_display ( $handle, [ $template_var = ''], [ $return_content = true], [ $include_once = false])
  • $handle
  • $template_var
  • $return_content
  • $include_once
assign_var (line 405)

Assign a single variable to a single key

  • access: public
void assign_var ( $varname,  $varval)
  • $varname
  • $varval
assign_vars (line 391)

Assign key variable pairs from an array

  • access: public
void assign_vars ( $vararray)
  • $vararray
destroy (line 122)

Destroy template data set

  • access: public
void destroy ()
destroy_block_vars (line 131)

Reset/empty complete block

  • access: public
void destroy_block_vars ( $blockname)
  • $blockname
display (line 161)

Display handle

  • access: public
void display ( $handle, [ $include_once = true])
  • $handle
  • $include_once
set_custom_template (line 78)

Set custom template location (able to use directory outside of phpBB)

  • access: public
void set_custom_template ( $template_path,  $template_name)
  • $template_path
  • $template_name
set_filenames (line 93)

Sets the template filenames for handles. $filename_array should be a hash of handle => filename pairs.

  • access: public
void set_filenames ( $filename_array)
  • $filename_array
set_template (line 50)

Set template location

  • access: public
void set_template ()
_tpl_include (line 593)

Include a separate template

  • access: private
void _tpl_include ( $filename, [ $include = true])
  • $filename
  • $include
_tpl_load (line 217)

Load a compiled template if possible, if not, recompile it

  • access: private
void _tpl_load ( &$handle)
  • &$handle

Documentation generated on Tue, 26 Aug 2008 08:34:09 +0200 by phpDocumentor 1.4.2