timber - 生产时嵌套块不尊重 page.twig
问题描述
问题:在生产环境中,Page.twig 没有按应有的方式呈现。Base.twig 改为渲染。在开发环境中一切正常。两个站点完全相等(克隆)。唯一的区别是生产在 Apache 上工作,而开发使用 Nginx。
- 使用 Timber Starter Theme 开发的主题。
- WordPress 5.5.1
- PHP 7.2
- 木材 1.18.0
页面.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 );
解决方案
推荐阅读
- python - 调用不同文件夹中的文件时导入错误
- python - 如何使用 selenium python 单击 javascript 超链接元素
- html - 显示背景图案的 CSS 透明 Bacground 图像
- java - 如何在 Spring Boot 中手动引导测试(没有 @SpringBootTest-Annotation)
- c++ - 在 C++ 中定义类范围常量的最佳方法
- c++ - 在线程中调用 OpenMP 的非常简单的代码中的内存泄漏
- javascript - 迭代 JSON 以创建导航
- mongodb - mongoDB 遍历文档键和总和值
- c++ - 我无法通过 vcpkg 导入 range-v3 库
- python - PYTHON - 合并日期索引上的两个数据框