Incompatibility with facets 3.0 and Views (better) exposed filters

Created on 23 January 2025, 4 months ago

Problem/Motivation

Facets appears to be moving in the direction of Views (better) exposed filters. My website now shows this warning on the facets overview page:

New in Facets 3: For new sites it is recommended to use the "Facets Exposed Filters" submodule for Facets on Views. This module uses native Views filters instead, which has many advantages.
Click here for documentation on how to use this new workflow.

And just below that:

Adding Facets as a block is still supported for backwards compatibility.

It is not unthinkable that the 'old' way of rendering might be phased out in the future.

When converting my view mode processed facet to a views filter, the only output is 'Array' because the Facets Exposed Filters (submodule of facets 3.0) is expecting to receive a string when it requests $result->getDisplayValue(). This module provides a render array instead.

Steps to reproduce

Configure a new facet in views and BEF module and enable the views view mode processor on it.

Proposed resolution

Instead of providing the render array, should this module maybe pre-render the facet result?

// Overwrite the result's display value.
$build = $view_builder->view($entity, $config['view_mode'], $language_interface->getId());
$rendered = \Drupal::service('renderer')->renderInIsolation($build); // <-- Render the view mode here.
$results[$i]->setDisplayValue($rendered);

Since views exposed filters are stripped from all markup, all that remains is text. Not what you would install this module for, but still better than having all options show 'Array' instead.

Remaining tasks

Decide on the approach? Perhaps it is also possible to lazy load the rendered output and skip the views sanitizing?

User interface changes

TBD

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇳🇱Netherlands neograph734 Netherlands

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024