PHP 8.6.0 Beta 3 is available for testing

Yaf_Controller_Abstract::render

(Yaf >=1.0.0)

Yaf_Controller_Abstract::renderRender view template

Descrizione

protected function Yaf_Controller_Abstract::render(string $tpl, ?array $parameters = ?): string|bool|null

Renders the view script tpl and returns the output, unlike Yaf_Controller_Abstract::display().

Elenco dei parametri

tpl

The view script name, relative to the view path.

parameters

An associative array of variables to export to the view script for this rendering.

Valori restituiti

The rendered output as a string on success, or false on failure.

Esempi

Example #1 Yaf_Controller_Abstract::render() example

<?php
class ProductController extends Yaf_Controller_Abstract
{
    public function indexAction() {
        // do not auto-render the default template
        Yaf_Dispatcher::getInstance()->disableView();

        // render product/index.phtml and return the output
        // instead of sending it directly (as display() would)
        $html = $this->render("product/index.phtml", array(
            "products" => array("yaf", "php"),
        ));

        // post-process and set it as the response body
        $this->getResponse()->setBody($html);
    }
}
?>

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top