Yaf_View_Simple::display

(Yaf >=1.0.0)

Yaf_View_Simple::displayRender and store a template in the response

Description

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

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

add a note

User Contributed Notes

There are no user contributed notes for this page.