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

how to set the main views directory?

I want to only change the main views directory,but I don't find the function like 'setMainDir'. how to set the main views directory?thanks.



1.5k
edited Apr '15

sorry,I have just read the source code, found can't do that



16.0k
Accepted
answer
edited Apr '15

you can set the main view, the default layout, layouts dir and partial dir

    $view->setLayoutsDir('/path/to/layouts/');
    $view->setPartialsDir( '/path/to/partials/');
    $view->setMainView('/path/to/default/view'); // notice the missing trailing slash
    $view->setLayout('defaultLayoutName');

If absolute paths don't work, try relative ones. Absolute paths might not work when your path is outside the module.