Twig 模板可以嵌套在OctoberCMS中吗?

Twig 模板可以嵌套在OctoberCMS中吗?,twig,octobercms,Twig,Octobercms,我已经开始关注十月,虽然我能够构建一个默认布局,并在需要的地方有条件地包含分部。我更喜欢鸟巢布局 也就是说,root布局不依赖于任何其他布局,但是nav布局引用了root布局 这可能吗 编辑: 我正在考虑更换ExpressionEngine。在EE中,我可以使用我的html>head+body标签来进行root布局。然后我可以有一个nav布局,它添加到导航中,但引用root布局作为其布局。因此,您最终得到了根目录,它被导航引用,或者可以被任何[页面]直接引用(如果不需要导航)。嵌套布局只允许我避

我已经开始关注十月,虽然我能够构建一个默认布局,并在需要的地方有条件地包含分部。我更喜欢鸟巢布局

也就是说,
root
布局不依赖于任何其他布局,但是
nav
布局引用了
root
布局

这可能吗

编辑: 我正在考虑更换ExpressionEngine。在EE中,我可以使用我的
html>head+body
标签来进行
root
布局。然后我可以有一个
nav
布局,它添加到导航中,但引用
root
布局作为其布局。因此,您最终得到了
根目录
,它被
导航
引用,或者可以被任何
[页面]
直接引用(如果不需要导航)。嵌套布局只允许我避免在
布局
页面
中有条件地包含部分。在我看来,这只是一个更干净的标记。另外,
root
nav
都有
{%page%}
标记来指示内容的位置

所以理想情况下

根布局


[常用标签]
{%page%}
导航布局

layout=“root”
==
[加价]
{%page%}
因此,当页面引用根目录时,将不显示导航。但是,当一个页面引用
nav
{%page%}
被注入
nav
时,
nav
+
{%page%}
的内容作为
{%page%}
内容传递到
根目录下


希望其他信息能有所帮助。

嵌套布局目前不受支持,但您可以通过和来完成这一点

下面是一个我目前用于导航的示例

layouts/with nav.htm:

description = "Layout with nav"

[staticMenu nav]
code = "header-nav"
==
{# Setup the navigation menus #}
{% put headerNav %}
    {% set hNavOptions = {
        'submenus': true
    } %}
    {% partial "tmpl/nav-header" menu=nav options=hNavOptions %}
{% endput %}

{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
description = "Layout without nav"
==
{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>{% placeholder page_title default %}{{ this.page.title }}{% endplaceholder %} | {{ app_name }}</title>

        {% partial "meta/icons" %}
        {% partial "meta/seo" %}

        {% partial "meta/styles" %}
    </head>
    <body class="page-{{ this.page.url | slugify }} layout-{{ this.layout.id }}">
        <!-- Header -->
        <header id="home" class="header-area">
            {% placeholder headerNav default %}
                <!-- headerNav not defined in page layout. -->
            {% endplaceholder %}
        </header>
description=“带导航的布局”
[静态菜单导航]
code=“标题导航”
==
{#设置导航菜单#}
{%put headerNav%}
{%set hNavOptions={
“子菜单”:真
} %}
{%partial“tmpl/nav头”菜单=导航选项=hNavOptions%}
{%endput%}
{%partial“tmpl/头”%}
{%page%}
{%partial“tmpl/footer”%}
布局/无导航。htm:

description = "Layout with nav"

[staticMenu nav]
code = "header-nav"
==
{# Setup the navigation menus #}
{% put headerNav %}
    {% set hNavOptions = {
        'submenus': true
    } %}
    {% partial "tmpl/nav-header" menu=nav options=hNavOptions %}
{% endput %}

{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
description = "Layout without nav"
==
{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>{% placeholder page_title default %}{{ this.page.title }}{% endplaceholder %} | {{ app_name }}</title>

        {% partial "meta/icons" %}
        {% partial "meta/seo" %}

        {% partial "meta/styles" %}
    </head>
    <body class="page-{{ this.page.url | slugify }} layout-{{ this.layout.id }}">
        <!-- Header -->
        <header id="home" class="header-area">
            {% placeholder headerNav default %}
                <!-- headerNav not defined in page layout. -->
            {% endplaceholder %}
        </header>
description=“无导航布局”
==
{%partial“tmpl/头”%}
{%page%}
{%partial“tmpl/footer”%}
partials/tmpl/header.htm:

description = "Layout with nav"

[staticMenu nav]
code = "header-nav"
==
{# Setup the navigation menus #}
{% put headerNav %}
    {% set hNavOptions = {
        'submenus': true
    } %}
    {% partial "tmpl/nav-header" menu=nav options=hNavOptions %}
{% endput %}

{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
description = "Layout without nav"
==
{% partial "tmpl/header" %}

    <!-- Content -->
    <div id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    {% page %}
                </div>
            </div>
        </div>
    </div>

{% partial "tmpl/footer" %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>{% placeholder page_title default %}{{ this.page.title }}{% endplaceholder %} | {{ app_name }}</title>

        {% partial "meta/icons" %}
        {% partial "meta/seo" %}

        {% partial "meta/styles" %}
    </head>
    <body class="page-{{ this.page.url | slugify }} layout-{{ this.layout.id }}">
        <!-- Header -->
        <header id="home" class="header-area">
            {% placeholder headerNav default %}
                <!-- headerNav not defined in page layout. -->
            {% endplaceholder %}
        </header>

{%placeholder page_title default%}{{this.page.title}}{%endplaceholder%}{{app_name}}
{%partial“元/图标”%}
{%partial“meta/seo”%}
{%partial“元/样式”%}
{%placeholder headerNav default%}
{%endplaceholder%}

我不太确定您对“嵌套布局”的要求,您能更深入地解释一下并提供示例吗?@LukeTowers查看问题更新。