- 7. API Reference
7.2. Opt_View class - 7.1.10. setup()
« Previous - 7.2.1. __construct()
Next »
7.2. Opt_View class
Table of Contents
- 7.2.1. __construct()
- 7.2.2. __get()
- 7.2.3. __isset()
- 7.2.4. __set()
- 7.2.5. __unset()
- 7.2.6. assign()
- 7.2.7. assignGlobal()
- 7.2.8. assignGroup()
- 7.2.9. assignGroupGlobal()
- 7.2.10. assignRef()
- 7.2.11. assignRefGlobal()
- 7.2.12. clear()
- 7.2.13. defined()
- 7.2.14. definedGlobal()
- 7.2.15. get()
- 7.2.16. getBranch()
- 7.2.17. getCache()
- 7.2.18. getGlobal()
- 7.2.19. getOutputBuffers()
- 7.2.20. getTemplate()
- 7.2.21. getTime()
- 7.2.22. hasDynamicContent()
- 7.2.23. inherit()
- 7.2.24. remove()
- 7.2.25. removeGlobal()
- 7.2.26. setBranch()
- 7.2.27. setCache()
- 7.2.28. setFormat()
- 7.2.29. setFormatGlobal()
- 7.2.30. setTemplate()
| Construct | Class |
|---|---|
| Versions | since 2.0-dev7 |
This class represents a view which is an OPT template and the data associated to it. The views can be rendered using the output systems or the opt:include instruction in the templates. It must be pointed that the view contains also all the inherited templates.
Using views
To use a view, we must begin with creating a view object. You should use different object for different templates in your script. Once this step is done, we may assign some data from the script. By default, they will be visible only for the view template, however - we are also able to create global template variables.
$view1 = new Opt_View('template_1.tpl'); $view2 = new Opt_View('template_2.tpl'); // Assign the data to local template variables $view2->bar = 'bar'; $view2->foo = 'joe'; $view1->foo = 'foo'; $view1->includedView = $view2; // Assign the data to global template variables Opt_View::assignGlobal('globalVar', 'foo'); // Render the views: $out = new Opt_Output_Http; $out->render($view1);
In order to display the $view2, the template template_1.tpl from $view1 must contain the following code:
<opt:include view="$includedView" />
- 7.2. Opt_View class
7. API Reference - « Previous
7.1.10. setup() - Next »
7.2.1. __construct()