【发布时间】:2017-09-30 15:54:47
【问题描述】:
我在 Drupal 中创建了一个include:
{% include directory ~ '/partials/header.html.twig' %}
但我收到此错误:
Twig_Error_Loader: Template "themes/custom/mytheme/partials/header.html.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "themes/custom/mytheme/partials/header.html.twig" in the Drupal theme registry.) in "themes/custom/mytheme/page--front.html.twig" at line 1. in Twig_Loader_Chain->getCacheKey() (line 115 of vendor/twig/twig/lib/Twig/Loader/Chain.php).
根据 Drupal 和 Twig 文档,我的做法是正确的。
我有一个名为partials 的目录和一个名为header.html.twig 的文件。
我做错了什么?我在 MAMP 和 OSX、El Capitan 中运行 Drupal。 Drupal 8.3.7
【问题讨论】:
-
您好,您清除缓存了吗?
-
是的,很多次!
-
您能否在主题上添加drupal plz的版本。您是否将主题附加到注册表,是一个新模块还是您覆盖了核心文件?
-
这是 Drupal 8.3.7 我没有将我的主题附加到注册表,不是一个新模块,我没有触及核心文件。
-
所以你有 2 个解决方案创建一个新模块制作一个挂钩以将 regitry 附加到你的模板或使用模板覆盖你,但这意味着你不能更新模板或首先覆盖核心解决方案是最好的,问候。在这里解决您的问题drupal.stackexchange.com/questions/25846/…