Note that conditional logic is allowed in D8 rewrites on module page

Created on 12 January 2018, over 6 years ago
Updated 7 November 2023, 8 months ago

In many cases in D8 this module may be obsolete, because using Twig for Views rewriting we can now use conditional logic. It would be helpful to note this on the module page in order to help reduce module bloat on systems that may not need the extra UI functionality that this offers.

In the field's rewrite section, we can use Twig conditionals to do the same thing. For example to display literal values:

{% if {{ field_type == "old" }} %}
OLD
{% else %}
NEW
{% endif %}

or to display view fields (fields must have already been loaded and be available under the Replacement Patterns section):

{% if {{ field_show_other_flag }} %}
{{ field_other_thing }}
{% else %}
{{ field_main_thing }}
{% endif %}

✨ Feature request
Status

Fixed

Version

1.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States diamondsea

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024