据我了解,Phalcon 使用index.phtml
or index.volt
inapp/views
作为任何没有指定模板的页面的基本模板。
我怎样才能改变它来使用app/views/layouts/common.volt
?
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
在设置视图组件时,我们需要像下面这样声明 $view 对象:
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->setLayout('common');
......
使用 setLayout(String name) 方法为应用设置默认布局