logo

views condition

admin
22 Apr 2020

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%}