1

I have a view. And I want to have some conditions for particular field name in a twig template. the template is views-view-fields.html . I have tried with devel modules also. But now getting. Please help.

code:

{% for field in fields -%} //if field.name == 'something' then do this {%- endfor %} 
5
  • 1
    There is no way to know what the field names should be only you would know that. You should install Twig XDebug + XDebug so you can set a breakpoint here and see the variables available. Commented Jul 21, 2017 at 13:43
  • Thank you. going the other way is it possible to override template for that field only? I tried even that but no luck. Commented Jul 21, 2017 at 13:48
  • I'm not sure. My 99% case for Views is to always render the entity in a designated view mode - then you render things as normal (view mode twig override, or fields) which are all respected. I really really avoid field based Views. Commented Jul 21, 2017 at 13:49
  • The problem is that I want to add a <video> tag in the rewrite result of a field in a view. But it is not working. what should be the reason. Commented Jul 21, 2017 at 14:08
  • This should really be handled with field rendering, which would be handled when rendering the content itself and not individual fields. Commented Jul 21, 2017 at 14:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.