Possibility to disable facets

Created on 19 October 2021, about 3 years ago
Updated 10 April 2024, 9 months ago

The status was removed from the facet settings form in that task https://www.drupal.org/project/facets/issues/2712509 β†’

We have the case that the same codebase is used by multiple sites and they can use different facets from existing.
For example, we have 400 facets, but only 50 are used on one site.

To improve the performance (initFacets function processing all existing facets) and avoid too many facets in the list (on layout builder or facets block), we want to be able to disable them all by default and let site admins enable only required ones.

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡·πŸ‡ΊRussia kiseleva.t

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡±Netherlands Web-Beest

    I've got the same problem as well (in need of facets that can be disabled when needed). I've found one little issue in the code; when the facetblock is built, it returns an error because the facet is not active.

    `Warning: Undefined array key "[facet_id]" in Drupal\facets\FacetManager\DefaultFacetManager->processBuild() (regel 323 van /app/web/modules/contrib/facets/src/FacetManager/DefaultFacetManager.php)`

    This is due to the fact that the facet hasn't been built yet, but isn't available in the list of facets because it's not loaded. So I've added a check in FacetBlock::build that checks the facet status and returns an empty array if disabled.

  • πŸ‡³πŸ‡±Netherlands Web-Beest

    Fix for broken blocks. This patch lets the FacetManager load all the blocks (disabled or not) but disables the rendering of the block that uses that facet. This way you can configure the blocks for all facets, but select which block should be rendered by disabling the facet.

  • Status changed to Needs work 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Probably would be good to get test coverage for this one.

Production build 0.71.5 2024