Bring harmony to your views

Drupal has its quirks. And the odd niggly bit. Most of the time the operational foible simply becomes second nature as we and our clients accept it as the way such and such part of Drupal works.

Sometimes, however, users are not so forgiving and that annoying little discomfort becomes a nag of a feature request. This is how Views Filter Harmonizer was born.

The module fixes a hard-coded behaviour in Views regarding filtering. It's a modest module, but judging by the uptake since its release a month ago a lot of people find this issue with Views rather irritating.

Normally, when a Views field has been assigned both an exposed filter and a contextual filter, then both filters get applied to the View's results set -- always. Check the view::build() function, if you like.

As a consequence, contradictory search clauses easily occur, causing a counter-intuitive user experience with some White Screens of Disillusionment. Since the contextual filter sets the "bounds", any filtering by the visitor through the exposed filter on that page can only narrow down the result set, not broaden it. In other words the exposed filter appears not to be working correctly.

Views Filter Harmonizer allows you to have a contextual filter argument apply only when there is no corresponding regular (exposed) filter value present, typical on initial page load. After that the contextual filter will silently retreat and let the exposed filter do its thing.

And so they lived together happily ever after.

The End

Picture: "The Partnership" by Andrew Baines

PS: just checked the Views D8 core code -- same behaviour is still there. Looks like this little baby needs to be dressed in D8 too...

File under: 

Views going global

Read More »