Reputation: 186552
From what I understand, Phalcon uses index.phtml
or index.volt
in app/views
as the base template for any page that doesn't have a template specified.
How can I change this to use app/views/layouts/common.volt
?
Upvotes: 1
Views: 2062
Reputation: 2699
It uses index.volt or index.html if the latest executed action is 'index' (indexAction in the controller).
You can use a common layout by setting a 'template before' or a 'template after':
https://github.com/phalcon/invo/blob/master/app/controllers/ContactController.php#L7
Update August 2016: since the above information is no longer available in the given link, adding it here:
public function initialize()
{
$this->view->setTemplateBefore('your-template-name');
$this->view->setTemplateAfter('your-template-name');
}
More info here: https://docs.phalconphp.com/en/latest/reference/views.html#using-templates
Upvotes: 3
Reputation: 975
When setting up the view component we need to declare $view Object like the following:
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->setLayout('common');
......
using setLayout(String name) method to set default layout for app
Upvotes: 1