1

据我了解,Phalcon 使用index.phtmlor index.voltinapp/views作为任何没有指定模板的页面的基本模板。

我怎样才能改变它来使用app/views/layouts/common.volt

4

2 回答 2

3

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

于 2013-11-12T18:36:08.003 回答
1

在设置视图组件时,我们需要像下面这样声明 $view 对象:

$di->set('view', function () use ($config) {

    $view = new View();

    $view->setViewsDir($config->application->viewsDir);
    $view->setLayout('common');
......

使用 setLayout(String name) 方法为应用设置默认布局

于 2014-03-25T07:38:13.830 回答