I have a view
that is outputting fields from a paragraph
. I want to be able to output different markup. There are two available values in the dropdown
1|Wrapping Link
2|Internal Link
and they should determine if the markup is wrapped by a link or if the same link is a contained within the markup as a stand-alone link.
In my custom version of views-view-fields.html.twig
I want to have some logic in place that will check the value of the dropdown and display the correct markup. I have tried the following but this is invalid.
{%- if {{ fields.field_banner_type.content }} = "1" -%}
// wrapping link
{%- else -%}
// no wrapping link
{%- endif %}
{% if fields.field_banner_type.content == 1 %} // wrapping link {% else %} // no wrapping link {% endif %}
// wrapping lnk
irrespective of the dropdown value selected. The field is outputting the value as opposed to the key so I'm guessing I need to get access to this// wrapping lnk
thats because the if condition verified, and the comment in twig should be like{#wrapping lnk #}
not// wrapping lnk
{% if fields.field_banner_type.content == 'Wrapping Link' %}
. Even if I set the formatter of the view for this filed tokey
I still had to set it as a string in the twig file - e.g.{% if fields.field_banner_type.content == '1' %}
. All good now. Thanks, @berramou