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 working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.