Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: MCP Sentinel 2.23.1 Minor update available for module mcp_sentinel (2.23.1). Release: Audit Chain 1.9.1 Minor update available for module audit_chain (1.9.1). Release: Menu Autopilot 1.4.1 Minor update available for module menu_autopilot (1.4.1). Release: GraphQL Compose Codegen 1.4.1 Minor update available for module graphql_compose_codegen (1.4.1). Release: Field Guard 1.3.1 Minor update available for module field_guard (1.3.1). Release: Webshare 2.0.1 Minor update available for module webshare (2.0.1). Release: Navigation + 2.3.10 Minor update available for module navigation_plus (2.3.10). Release: Edit + 2.3.4 Minor update available for module edit_plus (2.3.4). Module Revived: Flag for Someone Else 1.0.2 Module flag_fse updated after 9 months of inactivity (1.0.2). Security Coverage: smart 404 Module smart_404 now has official Drupal security advisory coverage.

Views field comparison

46 sites Security covered Drupal 10–11

Part of the Views ecosystem · 208 projects

View on drupal.org

This module allows you to compare fields within a Drupal Views query. You can filter or sort content based on direct comparisons between two fields or compare a field against a static value. This provides more flexibility for building advanced content displays.

Overview

The Field Comparison for Views module allows you to perform comparisons between fields within a Views query in Drupal 8 and beyond. This feature, originally part of the popular Views module in Drupal 7, enables you to filter or sort content based on field-to-field comparisons or field-to-static-value comparisons.

With this module, you can build advanced queries that compare values from different content fields, such as dates, numbers, text fields, and more. This gives you enhanced flexibility in controlling the display of your content and ensures that Views can meet more specific use cases for your Drupal site.

Key Features

Field-to-Field Comparisons: Compare fields directly within Views, such as checking if one date field is earlier or later than another.
Field-to-Static Value Comparisons: Compare a field against a fixed value (e.g., check if the price field is greater than $50).
Easy Integration: Seamlessly integrates into the Views interface, allowing for intuitive configuration directly from the Views UI.
Flexible Filtering and Sorting: Add field comparison conditions to your Views filters or sort criteria, enabling powerful content displays.
Drupal 8+ Compatibility: Fully ported and maintained for Drupal 8 and later versions.

Usage

Creating a View with Field Comparison:
When editing a view, add a new filter or sort criterion.
Select the field you want to compare.
Choose the comparison operator, such as =, >, <, !=, etc.
Optionally, select another field to compare it to or input a static value.
Examples:
Date Comparison: Display content where start_date is greater than the end_date.
Number Comparison: Show all products where the price field is less than 100.
For more detailed examples, check the module documentation or issue queue.

Develop Views field comparison using DDEV ⚙

If you haven't already, install DDEV.

git clone [email protected]:project/views_field_comparison.git
cd views_field_comparison
ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=views-field-comparison
ddev add-on get ddev/ddev-drupal-contrib
ddev add-on get s-ayers/ddev-drupal-contrib-mkdocs
ddev start
ddev poser
ddev symlink-project
ddev drush site:install -y
ddev drush pm:install views_field_comparison -y
ddev drush config:export -y
ddev drush user:login

Consider sponsoring DDEV development.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Oct 2024
Latest release
1 month ago
Releases (12 mo)
1 ▼ from 2
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.1 Stable 10–11 Aug 5, 2026
1.0.0 Stable 10–11 Oct 18, 2024
1.0.x-dev Dev 10–11 Oct 18, 2024