logo

views in drupal 8

01 Jun 2023

Show Related Content by Category Using Views Drupal 8 or 9

Published On: Thu, 06/01/2023 - 11:20

Follow these step to make block using views to show the related content according to category of the current content page.

Edit the views and open Advance section

  1. Add the  'Content: Has taxonomy term ID' in CONTEXTUAL FILTERS.
  2. Check 'Provide default value' option and then select the 'Taxonomy term ID from URL'.

 …

01 Mar 2021

Page Template for Views Page

Published On: Mon, 03/01/2021 - 12:13

If you want to create template for views page like page.tpl.twig so you follow these step. Whole page template for views page.

  1. Create copy of page.tpl.twig
  2. If your views url is ‘news-and-articles’ then rename file as ‘page--news_and_articles.html.twig’ and upload in your themes folder. If url has dash then replace dash with underscore.

After clear cache current template will work for this views instead of page.tpl.twig.

22 Apr 2020

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

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…