首页 > 解决方案 > 生产时嵌套块不尊重 page.twig

问题描述

问题:在生产环境中,Page.twig 没有按应有的方式呈现。Base.twig 改为渲染。在开发环境中一切正常。两个站点完全相等(克隆)。唯一的区别是生产在 Apache 上工作,而开发使用 Nginx。

页面.twig

{% extends "base.twig" %}

{% block center_section %}
    <section id="content" role="main" class="container">
        <div class="row">
            <div class="col-12 p-0 mb-4">
                {% block content %}
                    <h1 class="h2 font-libre m-0">{{post.title}}</h1>
                    <div class="content-wrapper">
                        <article class="post-type-{{post.post_type}} card content-wrapper border-0 no-border-radius p-3" id="post-{{post.ID}}">
                            <section class="article-content">
                                <div class="article-body">
                                    {{post.content}}
                                </div>
                            </section>
                        </article>
                    </div><!-- /content-wrapper -->
                {% endblock %}
            </div>
        </div>
    </section>
{% endblock %}

页面.php

$context = Timber::context();
$timber_post     = new Timber\Post();
$context['post'] = $timber_post;
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );

标签: timber

解决方案


推荐阅读