Please tell me how to invalidate the template once set with the setTemplateAfter method on Phalcon 3 so as not to refer to the template.
The current configuration is extended by IndexController ControllerBase.
In the initialize method of ControllerBase, set the template with setTemplateAfter as follows.
$this->view->setTemplateAfter('common');
In the expanded IndexController, since the template is unnecessary, an error occurs although the following is executed.
$this->view->setTemplateAfter('');
*I am thinking that I do not want to change to ControllerBase as much as possible because the template is used by another controller.
View 'layouts/' was not found in any of the views directory
#0 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'layouts/', false, true, NULL)
#1 [internal function]: Phalcon\Mvc\View->render('index', 'index')
#2 /mnt/raid/serverapps/www/lashca/public/index.php(42): Phalcon\Mvc\Application->handle()
#3 {main}
controllers/ControllerBase.php
<?php
use Phalcon\Mvc\Controller;
class ControllerBase extends Controller
{
public function initialize()
{
$this->view->setTemplateAfter('common');
}
}
controllers/IndexController.php
<?php
use Phalcon\Mvc\Controller;
class IndexController extends ControllerBase
{
public function indexAction()
{
$this->view->setTemplateAfter('');
}
}
You can disable certain levels of view rendering via $this->view->disable()
.
For example, if you want to disable the "template after"-rendering you can do this:
$this->view->disableLevel([
View::LEVEL_AFTER_TEMPLATE => true
]);
Check the documentation if you want to disable other levels of the view.