繁体   English   中英

将默认模板更改为“common.volt”?

[英]Change default template to 'common.volt'?

根据我的理解,Phalcon在app/views使用index.phtmlindex.volt作为未指定模板的任何页面的基本模板。

如何更改此设置以使用app/views/layouts/common.volt

如果最新执行的操作是'index'(控制器中的indexAction),它使用index.volt或index.html。

您可以通过设置'模板之前'或'模板之后'来使用通用布局:

https://github.com/phalcon/invo/blob/master/app/controllers/ContactController.php#L7

2016年8月更新 :由于上述信息在给定链接中不再可用,请在此处添加:

public function initialize()
{
    $this->view->setTemplateBefore('your-template-name');
    $this->view->setTemplateAfter('your-template-name');
}

更多信息: 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)方法为app设置默认布局

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM