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

php templating - override ../views/index.phtml method?

Hi,

Is there any way to override the Main Layout ../views/index.phtml for a specific action? I found a way of doing it with: view->setViewsDir('../app/alternative_views'); and I was wonder if can be achieve in a different way (something like ->setMainLayout('alternative_index').

Best regards, Razvan



98.9k
Accepted
answer

You can use Phalcon\Mvc\View::setMainView to change the location of that file.

https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_View.html#methods



786

All right! That's very elegant! Thank You very much!

Razvan