We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to change the to-be-renderable .phtml file in controller?

say, Im in:

<?phppublic function indexAction()
{
}

no matter whay I am doing, the index.phtml will be generated. But due to a reason, sometimes "index2.phml" must be rendered. So, how to say what file to render?



93.7k
Accepted
answer
$this->view->pick(array('templates/edit'));

If you dont change any rules for generating views default action is :

If controller dont return anything and you didnt change any rules for generating views then -> its searching for directory with controller name -> its picking view called as action(so if you have showAction - show, indexAction - index etc) -> and its rendering this view.