How to add condition in views with custom field in DRUPAL 8

22
April

How to add condition in views with custom field in DRUPAL 8
By: Anonymous | Published On: Wed, 04/22/2020 - 22:13

If you want to add if condition in my "global custom text" field in views Drupal 8

Example 1: Check node status and put conditional link according to publish status

{% if  status  %}
   put your HTML as condition
{% endif %}

Example 2: In this example we are checking a field value is empty or not. according to value in we are showing link or status

{% if  field_final_layout_date is empty %}

put your HTML as condition

{% else %}

Completed

{% endif %}

Example 3: In this example we are checking field value is empty or not with and operator

If field state and field city is not empty then print our output as your required

In else section you can put output as your required

{% if  field_state and  field_city  %}
	// Output
{% else %}
	// Output
{% endif %}

Example 4: Here we are checking city value and copare value as our required

If field city have value Delhi then print our output as required. You can check field machine name in replacement pattern

{% if field_city == "Delhi" %}
	// Output
{%endif%}

Comments

Need Help ?