Drupal: Working with filters criteria

A View filter restricts the entities displayed by the View to only those match the specific criterion.

When creating the initial View, and selected the type of content Articles & Published to view, there we can add filters.

Go to the View you created, like admin/structure/views/view/articles and click on the Add button next to the Add Filter criteria, you will be displayed a dialog where you can select additional filters.

Filters Dialog box

There are different filters that can be applied to filter the content. Drupal 8 allows content to be filtered by (access permissions, comments, taxonomies, or any field attached to the content itself).

For instance, if we want to display the Articles those are published since last week. To do so we will select Changed from the list from the Filters dialog box and click the Add and configure filter criteria.

Since Changed is a date field, we can use several operators to filter the Articles. For example date or date range. To get the Article published since last week, we will select Operator “Is greater than or equal to” then select Value type “An offset from the current time such as “+1 day” or “-2 hours -30 minutes” and enter value “-7 days” then click the button Apply.

Find the required field:

Set the required criteria:

That’s it, now click on Apply and you are good to go. You Articles list/page will be filtered by give criteria.

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk