Yaf_View_Simple::display

Render and store a template in the response

Description

public bool Yaf_View_Simple::display(string $tpl, array $vars = NULL)

Renders a template and appends the result to the Yaf_Response_Abstract body.

Note: Unlike Yaf_View_Simple::render, the result is not returned but stored in the response, and Yaf_Application sends it when the response is emitted.

Parameters

tpl
The path to the template, relative to the template directory set by Yaf_View_Simple::setScriptPath or application.view.directory.
vars
Optional variables to assign for this template only; they override assigned variables with the same name.

Return Values

Returns true on success, or false on failure.

Examples

Example #1 Yaf_View_Simple::display example

<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $this->getView()->assign("title", "My Homepage");

        /* render index/index.phtml and store the result
         * in the response body */
        $this->getView()->display("index/index.phtml");

        return false; // we rendered ourselves, skip auto-rendering
    }
}
?>

Example #2 Template example

<html>
 <head>
  <title><?php echo $title; ?></title>
 </head>
</html>

See Also

  • Yaf_View_Simple::render
  • Yaf_View_Simple::assign