PHP Template Function: LoadTemplate
Posted by Mark [Elevated X Support], Last modified by kayako kayako on 02 November 2018 10:37 AM
|
|
Description: This is the standard function used to load a subtemplate from a regular CMS template. It differs from a regular PHP call such as include by: 1) Variables that are declared within the existing template won't get assigned in the subtemplate UNLESS they are explicitly passed along. 2) Global variables (viewed by adding debug=1 to the members/template URL) declared by the CMS engine are available within the subtemplate automatically. Common Location: /cms_admin/phptemplate/<templatefolder>/functions/standard.tpl Usage: <?php LoadTemplate("template_sections/template.tpl"); ?> <?php LoadTemplate("template_sections/template.tpl", ["varname" => 1]); ?> Arguments 1) The first argument is the path to the template that should be loaded. 2) The second argument is a list of variables that should be included into the global scope once this template is included. Within the second example above, an array is passed along with ["varname" => 1]. Within template.tpl, a variable name called $varname will be available, and its value is set to 1. | |
|