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.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 3255454-fix-no-results-issue.patch | 2.51 KB | 3cwebdev |
Issue fork facets-3255454
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
Comment #3
danielehrenhoferComment #4
danielehrenhoferComment #5
danielehrenhoferAdded organisation
Comment #6
danielehrenhoferComment #7
danielehrenhoferComment #8
danielehrenhoferComment #9
danielehrenhoferComment #10
danielehrenhoferComment #11
danielehrenhoferAdded organization
Comment #12
mkalkbrennerFor whatever reason the tests in the new sub-module aren't executed. Maybe they will be executed after commit?
Comment #14
danielehrenhoferComment #15
mkalkbrennerComment #17
marksmith commentedThis 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.
Comment #18
timwoodGreat 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?
Comment #19
mkalkbrennerOpen an issue.
Open an issue.
Comment #20
timwoodDone! Sorry I didn't do that to begin with. https://www.drupal.org/project/facets/issues/3264720
Thank you.
Comment #21
smustgrave commentedTried 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
Comment #22
foodslover commentedWonderful 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.
Comment #23
3cwebdev commentedAs "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.
Comment #24
3cwebdev commentedPatch 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"
Comment #25
smustgrave commented@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.