Package: IO\Template\data Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Benoit SAUTEL Version: PHPBoost 5.2 - last update: 2015 06 25 Since: PHPBoost 3.0 - 2010 02 19 Contributor: Julien BRISWALTER Located at: io/template/data/TemplateData.class.php

This interface describes data which are assigned to a template. There are two types of data:

  • Variables: there are string that are directly displayed
  • Templates: you can embed a template in another one. When a subtemplate is displayed, it's parsed using its own data and the result is inserted where the subtemplate is embedded.

A template contains global variables which are available in the whole template and local variable which are only defined into a loop. To define a loop, you just have to use assign_block_vars with the same loop identifier for each loop iteration. Loops can be nested and embed both variables and subtemplates.

Direct known implementers
Methods summary
# enable_strict_mode( )

Enables the strict mode. If a variable that does not exist in the object is requested, then an exception will be raised.

# disable_strict_mode( )

Disables the strict mode. If a variable that does not exist in the object is requested, then an empty value will be returned.

# auto_load_frequent_vars( )

Loads the most common vars which are useful in the whole PHPBoost templates. The variables are:

  • THEME the theme used by the current user
  • LANG the lang used by the current user
  • IS_USER_CONNECTED tells whether the user is connected (member, moderator or administrator)
  • IS_ADMIN tells whether the user is administrator
  • IS_MODERATOR tells whether the user is moderator
  • PATH_TO_ROOT is the path which starts from the domain root (in HTTP context) and goes to the PHPBoost root. For instance if PHPBoost is installed at, its value will be /directory.
  • PHP_PATH_TO_ROOT is the server side path, it's the path which goes to the PHPBoost's root.
  • TOKEN is the CSRF protection token. It's to use in the critical actions to show that the user really intended doing the action
  • REWRITED_SCRIPT the current url
# put( $key, $value )

Assigns the value


to the template variable of name

# put_all( array $vars )

Assigns template variables. It could be simple variables, loop or subtemplates.

# assign_block_vars( string $block_name, array $array_vars, array $subtemplates = array() )

Assigns a template block. A block represents a loop and has a name which be used in your template file to indicate which loop you want to browse. To know what syntax to use to browse a loop, see the class description, there are examples.

public mixed[]
# get_block( string $blockname )

Returns the block $blockname in the template block list

public mixed[]
# get_block_from_list( string $blockname, mixed[] $parent_block )

Returns the block $blockname in the parent_block

public boolean
# is_true( string $value )

Tells whether a condition is true. Conditions are global boolean variables.

public string
# get( string $varname )

Returns the $varname variable content searched in from the $list

public string
# get_from_list( string $varname, mixed[] & $list )

Similar from the get_var method but it works with loop variables instead of global variables.

# bind_vars( TemplateData $data )

Binds vars on another TemplateData object. The two instances will share the same data.