Function __global->do_template

Definitions

sources/tempcode.php

  • Get a Tempcoded version of a software template. It is perhaps the most common function to load up templates using do_template, and then attach them together either as parameters to each other, or via the Tempcode attach method.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: object

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$codename ID_TEXT No No required parameter N/A N/A The codename of the template being loaded
$parameters array No No [] N/A N/A A map of parameters for the template (key to value); you can have any number of parameters of any name, there is no set standard; having a _GUID parameter of random value is a convention
$lang ?LANGUAGE_NAME No No Null N/A N/A The language to load the template in (templates can embed language references) (null: users own language)
$light_error boolean No No False N/A N/A Whether to not produce a stack trace if the template is missing
$fallback ?ID_TEXT No No Null N/A N/A Alternate template to use if the primary one does not exist (null: none)
$suffix string No No .tpl .tpl .js .xml .txt .css N/A File type suffix of template file (e.g. .tpl)
$directory string No No templates templates javascript xml text css N/A Subdirectory type to look in
$theme ?ID_TEXT No No Null N/A N/A Theme to use (null: current theme)
$non_custom_only boolean No No False N/A N/A Whether to only search in the default templates

Returns

  • The Tempcode for this template
  • Type: Tempcode
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Get a Tempcoded version of a software template. It is perhaps the most common function to load up templates using do_template, and then attach them together either as parameters to each other, or via the Tempcode attach method.
 *
 * @param  ID_TEXT $codename The codename of the template being loaded
 * @param  array $parameters A map of parameters for the template (key to value); you can have any number of parameters of any name, there is no set standard; having a _GUID parameter of random value is a convention
 * @param  ?LANGUAGE_NAME $lang The language to load the template in (templates can embed language references) (null: users own language)
 * @param  boolean $light_error Whether to not produce a stack trace if the template is missing
 * @param  ?ID_TEXT $fallback Alternate template to use if the primary one does not exist (null: none)
 * @param  string $suffix File type suffix of template file (e.g. .tpl)
 * @set .tpl .js .xml .txt .css
 * @param  string $directory Subdirectory type to look in
 * @set templates javascript xml text css
 * @param  ?ID_TEXT $theme Theme to use (null: current theme)
 * @param  boolean $non_custom_only Whether to only search in the default templates
 * @return Tempcode The Tempcode for this template
 */

function do_template(string $codename, array $parameters = [], ?string $lang = null, bool $light_error = false, ?string $fallback = null, string $suffix = '.tpl', string $directory = 'templates', ?string $theme = null, bool $non_custom_only = false) : object