We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.8k
Accepted
answer

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

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



781

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

Razvan