1
是否有任何方法可以为自定义内容类型制作自定义page.html.twig,例如 page - node - content-type.html.twig?Drupal 8 page.html.twig每种内容类型
目前我们得到 页 - 节点 - 。%html.twig ...
是否有任何方法可以为自定义内容类型制作自定义page.html.twig,例如 page - node - content-type.html.twig?Drupal 8 page.html.twig每种内容类型
目前我们得到 页 - 节点 - 。%html.twig ...
把下面的代码到你的theme_name.theme文件
function theme_name_theme_suggestions_page_alter(array &$suggestions, array $variables) {
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$content_type = $node->bundle();
$suggestions[] = 'page__'.$content_type;
}
}
那么对于 '自定义' 内容键入你可以创建'page - custom.html.twig'文件。