【问题标题】:Zend framework 2 and Twig (with the ZfcTwig module) - losing layout template content if action template is renderedZend 框架 2 和 Twig(带有 ZfcTwig 模块) - 如果呈现动作模板,则会丢失布局模板内容
【发布时间】:2013-02-05 19:46:59
【问题描述】:

我正在尝试将 ZF2 与 ZfcTwig 模块一起使用。我有骨架应用程序的基本结构: view->layout->layout.phtml (或 layout.twig) 视图->应用程序->索引->index.phtml(或index.twig)

如果我使用下一对:layout.twig 和 index.phtml - ZfcTwig 模块正确渲染 layout.twig,则 index.phtml(默认渲染)的结果也是正确的。

但是,如果我尝试将内容模板用作树枝模板(两个树枝文件) - 我只会得到具有正确渲染的 index.twig,但没有来自布局模板(layout.twig 甚至 layout.phtml)

有人有同样的情况吗?

【问题讨论】:

  • 更新:ZfcTwig 模块有下一个选项:'disable_zf_model' => false 这会关闭第二层渲染。打开它会改变这种情况,但我不确定这是正确的方法。

标签: layout zend-framework2 twig


【解决方案1】:

您可以使用 twig 布局,它与 ZfcTwig 配合得很好

在 index.twig 中

{% extends 'layout/layout.twig' %}

{% block content %}
    Here your template
{% endblock content %}

在 layout.twig 中

{% block content %}{{ content|raw }}{% endblock content %}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-30
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多