Problem/Motivation

In our project, we needed the ability to search/filter client-side within the checkbox and links widgets.

Our solution was to create a new searchbox widget (facets_searchbox_widget) that extends the existing checkbox and links functionality.

For this, the facets-item-list.html.twig template is overwritten.

The two templates used are the following:

  • facets-item-list--searchbox-checkbox.html.twig
  • facets-item-list--searchbox-links.html.twig

In both templates, a text input and a CSS class on the list were added (for selection via JavaScript).

The widget comes with a few basic CSS classes, but was essentially designed so that it can be easily adapted to your own layout. To prevent other dependencies, no additional JavaScript libraries were used.

We think it could be a useful extension for the module.

CommentFileSizeAuthor
#24 3255454-fix-no-results-issue.patch2.51 KB3cwebdev

Issue fork facets-3255454

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

danielehrenhofer created an issue. See original summary.

danielehrenhofer’s picture

danielehrenhofer’s picture

danielehrenhofer’s picture

Added organisation

danielehrenhofer’s picture

danielehrenhofer’s picture

danielehrenhofer’s picture

danielehrenhofer’s picture

danielehrenhofer’s picture

danielehrenhofer’s picture

Added organization

mkalkbrenner’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

For whatever reason the tests in the new sub-module aren't executed. Maybe they will be executed after commit?

danielehrenhofer’s picture

mkalkbrenner’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

marksmith’s picture

This is a very useful enhancement indeed! However, this widget appears to work for me only if URL alias of the facet is the same as the facet's machine name. I don't know whether this is intentional, but there can be cases where this is not the usual scenario.

timwood’s picture

Great new addition! Right now the facet item search box seems to provide a "starts with" type of search capability. Is it possible to change or configure this to be a "contains" style search?

mkalkbrenner’s picture

This is a very useful enhancement indeed! However, this widget appears to work for me only if URL alias of the facet is the same as the facet's machine name. I don't know whether this is intentional, but there can be cases where this is not the usual scenario.

Open an issue.

Great new addition! Right now the facet item search box seems to provide a "starts with" type of search capability. Is it possible to change or configure this to be a "contains" style search?

Open an issue.

timwood’s picture

Open an issue

Done! Sorry I didn't do that to begin with. https://www.drupal.org/project/facets/issues/3264720

Thank you.

smustgrave’s picture

Tried this This is a very useful enhancement indeed! However, this widget appears to work for me only if URL alias of the facet is the same as the facet's machine name. I don't know whether this is intentional, but there can be cases where this is not the usual scenario.

But the filter doesn't work for me still. Everything I try just returns No results.

Would consider reopening

foodslover’s picture

Wonderful Enchantments! however I have a search page with multiple facets, this widget appears to work for the top one facet only. Others just returns No result.

3cwebdev’s picture

As "smustgrave" pointed out above, the facet URL alias must match the facet's machine name or else you will always get "no results found". So, if you've changed your alias to be something more friendly then the search functionality fails.

3cwebdev’s picture

StatusFileSize
new2.51 KB

Patch attached to fix "no result" issue when patch alias does not match machine name. Also changed "no result" to the standard wording of "no results"

smustgrave’s picture

@3CWebDev I would recommend opening a new ticket. People have been reporting on this for almost a year and it hasn't been reopened so likely it's ignored.