简体   繁体   English

在Drupal 8中查看主题覆盖

[英]View theme override in drupal 8

I am new to drupal 8 and i need to override a views template. 我是drupal 8的新手,我需要覆盖视图模板。 So, for that I have enabled theme debug in services.yml to view the twig template suggestion name. 因此,为此,我在services.yml中启用了主题调试,以查看树枝模板建议名称。

This is my view theme debug. 这是我的视图主题调试。

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_unformatted__test_content_view' -->
<!-- FILE NAME SUGGESTIONS:
   x views-view-unformatted--test-content-view.html.twig
   x views-view-unformatted--test-content-view.html.twig
   * views-view-unformatted.html.twig
-->

Then, I created the file in templates of drupal8 theme and the theme file calls. 然后,我在drupal8主题模板和主题文件调用模板中创建了该文件。 I used themename_views_view_unformatted__test_content_view() function to override in themename.theme file but the function doesn't called. 我使用themename_views_view_unformatted__test_content_view()函数覆盖themename.theme文件,但未调用该函数。

Is there anyway to override the variables coming to the twig template. 无论如何,有没有要覆盖到树枝模板的变量。 Can anyone give me suggestion to override the views template. 任何人都可以给我建议覆盖视图模板。

Thanks in advance. 提前致谢。

The template name is views-view-unformatted.html.twig , to override the variables in this template implement the preprocess hook for that template in your themename.theme file. 模板名称为views-view-unformatted.html.twig ,以覆盖此模板中的变量,从而在themename.theme文件中实现该模板的预处理钩子。 Eg 例如

function themename_preprocess_views_view_unformatted(&$variables) {
  // Implement logic here to override the variables.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM