Yaf_View_Simple::__construct
Constructor of Yaf_View_Simple
Description
public Yaf_View_Simple::__construct(string $template_dir, array $options = NULL)
Yaf_View_Simple is the default and only view engine Yaf supports out of the box. An instance is created automatically by the Yaf_Dispatcher when the application starts; instantiating it directly is only needed to render templates outside of the dispatch flow.
The template_dir argument must point to an existing directory containing the view scripts; it becomes the script path of the view and can later be changed with Yaf_View_Simple::setScriptPath.
Parameters
-
template_dir
-
The directory where the template scripts are stored.
-
options
-
Optional view options as an array. Reserved for custom view engine implementations; the built-in engine accepts but does not use it.
Return Values
No value is returned.
Examples
Example #1 Yaf_View_Simple::__construct example
<?php
define("TEMPLATE_DIRECTORY", APPLICATION_PATH . '/views');
$view = new Yaf_View_Simple(TEMPLATE_DIRECTORY);
$view->assign("name", "world");
echo $view->render("greeting.phtml");
?>
See Also
- Yaf_View_Simple::render
- Yaf_View_Simple::display
- Yaf_View_Simple::setScriptPath