Example Page
This is an Example page to show several features of Xframes2. Please have a look around.
Get Variables
- p => example
- q => firstContent/anotherExample/Oh Really Now
- 0 => firstContent
- 1 => anotherExample
- 2 => Oh Really Now
Xframes2 Environment
$XF->Environment
You can assign get variables to any Xframes2 variable you want, and it's fail safe! And access them via the XF::Environment or via Smarty directly.
To see what it actually does click this.
PHP Part
/** * @author nanashiRei * * */ class PageExample extends XFrames { function __construct() { parent::__construct(); $this->caching = false; } public function DisplayPage() { $this->assignEnvironment('var1','othervar','whatever'); $this->display('examplePage.tpl'); } }
Template Part
<table> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {foreach $XF->Environment as $var} <tr> <td>$XF->Environment['{$var@key}']</td> <td>{$XF->Environment[$var@key]}</td> </tr> <tr> <td>${$var@key}</td> <td>{${$var@key}}</td> </tr> {/foreach} </tbody> </table>
Result
| Variable | Value |
|---|---|
| $XF->Environment['var1'] | firstContent |
| $var1 | firstContent |
| $XF->Environment['othervar'] | anotherExample |
| $othervar | anotherExample |
| $XF->Environment['whatever'] | Oh Really Now |
| $whatever | Oh Really Now |