System:Template:display
From Aspen Documentation
Displays all templates loaded and set for display. This function is to be used from within your class code.
Since 1.0
Contents |
Arguments
void' display ([array $data = false])
- data
- An array of key/values may be passed as an argument. The values will be assigned to variables with the names of the keys, and may be access from within your template using the key as the variable name.
Notes
- If template caching has been enabled, the templates will be cached after they've been included. Templates will be included with output buffering turned on.
- The file will only be included if it exists.
Examples
In this example we add three templates for inclusion. We then call the display method while also passing an array of data.
The array of data will be provided to our template.
$data = array('first'=>'John','last'=>'Doe'); $this->APP->template->addView($this->APP->template->getTemplateDir().DS . 'header.tpl.php'); $this->APP->template->addView($this->APP->template->getModuleTemplateDir().DS . 'index.tpl.php'); $this->APP->template->addView($this->APP->template->getTemplateDir().DS . 'footer.tpl.php'); $this->APP->template->display($data);
Inside of our template, we could then access the data by calling:
print $first; // John print $last; // Doe