在这个答案之后,我试图使用钩子_主题_建议_钩子覆盖core/themes/seven/templates/node-add-list.html.twig。
因此,我在modules/custom/domain_filter/domain_filter.module中添加了以下函数
function domain_filter_theme_suggestions_node_add_list(array $variables) {
$suggestions = [];
$suggestions[] = 'node_add_list__' . 'custom';
return $suggestions;
}我在我的模块中创建了自定义小枝文件:modules/custom/domain_filter/templates/node-add-list--custom.html.twig
这个建议在主题调试中看上去很好,但没有应用( x在node-add-list.html.twig前面):
如何应用node-add-list--custom.html.twig?
发布于 2018-09-13 09:39:52
最后我找到了文件中的一段。在使用模块时,我们需要使用HOOK_theme()注册模板。因此,我在modules/custom/domain_filter/domain_filter.module中添加了以下函数
/**
* Implements hook_theme().
*/
function domain_filter_theme() {
return [
'node_add_list__custom' => [
'base hook' => 'node_add_list',
],
];
}然后,我的定制模板modules/custom/domain_filter/templates/node-add-list--custom.html.twig现在被应用了。
发布于 2018-09-13 08:30:12
你需要添加你的主题
themes/yourtheme/templates/node-add-list--custom.html.twighttps://drupal.stackexchange.com/questions/269254
复制相似问题