Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_DispatcherYaf_Dispatcher::catchException>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026

Yaf_Dispatcher::autoRender

(Yaf >=1.0.0)

Yaf_Dispatcher::autoRender — Switch on/off autorendering

Description

public function Yaf_Dispatcher::autoRender(?bool $flag = null): Yaf_Dispatcher|bool

Yaf_Dispatcher will render the view automatically after dispatching an incoming request. You can prevent the rendering by calling this method with flag false.

Note:

You can also simply return false in an action to prevent the auto-rendering of that action only.

Parameters

flag

Whether to enable auto-rendering.

Note:

Since Yaf 2.2.0, if this parameter is not given, the current state is returned instead.

Return Values

Returns the Yaf_Dispatcher object itself when flag is given, or a bool indicating whether auto-rendering is enabled when it is not.

Examples

Example #1 Yaf_Dispatcher::autoRender() example

<?php
class IndexController extends Yaf_Controller_Abstract {
     /* init method will be called as soon as a controller is initialized */
     public function init() {
         if ($this->getRequest()->isXmlHttpRequest()) {
             //do not call render for ajax request
             //we will output a json string
             Yaf_Dispatcher::getInstance()->autoRender(FALSE);
         }
     }
}
?>

See Also


<Yaf_DispatcherYaf_Dispatcher::catchException>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026