I am new to drupal 8 and i need to override a views template. So, for that I have enabled theme debug in services.yml to view the twig template suggestion name.

Normal view theme debug.

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_unformatted' -->
<!-- BEGIN OUTPUT from 'themes/custom/cohesion/templates/views/views-view-unformatted.html.twig' -->

This is my view theme debug when in have views-view-unformatted--test-view.html.twig in my theme.

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

I used both the theme hook suggestion(preprocess) function to override in mytheme.theme file and the function calls. But inside the function the variable argument is empty inside that function. So i cant able to get the field values from my view in preprocess function.

Is there anyway to override the variables coming to the twig template. Can anyone give me suggestion to override the views template.

Files: 
CommentFileSizeAuthor
#2 2525732.1.patch2 KBwebflo
None View

Comments

praveen@ewall’s picture

Issue summary: View changes
webflo’s picture

Status: Active » Needs review
FileSize
2 KB
None View

Views uses multiple theme hooks instead of theme suggestions. I think we should add theme hooks to twig debug similar to template suggestions.

webflo’s picture

Project: Views » Drupal core
Version: 8.x-3.x-dev » 8.0.x-dev
Component: Miscellaneous » theme system
Category: Support request » Bug report
Issue tags: -views, -Drupal 8.x, -theme +DX (Developer Experience)
webflo’s picture

Issue tags: +TX (Themer Experience)
cilefen’s picture

Title: Views theme override in drupal 8 » Add theme hooks to twig debug
Category: Bug report » Task
cilefen’s picture

There is test coverage for twig debug, so this would need test coverage expanded.

The issue summary needs an update to explain why this is a task and to reference the original report.

This also needs a beta evaluation, which should be easy, because twig debugging messages are markup, so this is "unfrozen".

cilefen’s picture

Issue tags: +Twig
lauriii’s picture

praveen@ewall’s picture

Thanks for the help :)

Can u suggest any steps to override the field value in particular view using preprocess function or in twig template.