Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am using the checkboxes in my facets and would like to hide the facet counts that show up, how can this be achieved?
Comment | File | Size | Author |
---|
Comments
Comment #1
cpliakas CreditAttribution: cpliakas commentedHi BeaPower.
You can do this via theme hook overrides. See #1396348: Option to remove the link count satisfying a different use case, but using the same technique you will need to no show the facet counts.
Thanks,
Chris
Comment #2
cpliakas CreditAttribution: cpliakas commentedMarking as fixed after weeks of inactivity.
Comment #4
nedjo#1615430: How to hide facet counts? was closed as a duplicate.
You can achieve this in a preprocess function:
Comment #5
kopeboy CreditAttribution: kopeboy commentedI think it's incredible we don't have a checkbox in the configuration UI to disable this for a particular search filter.
This is basic stuff imho, when you have thousands of results, especially if the filter is the primary one (having multiple dependent filters), you usually don't want to show the number.
I don't have the skills to do this with php, if the feature won't come, can anyone provide some instructions to hide the facet count for a particular filter with the php snippet noted above?
Thanks
Comment #6
kitikonti CreditAttribution: kitikonti commentedBecause i also need this feature i tried to create a patch so we you enable or disable the count from the ui. But i have a problem with the checkbox. I created a new checkbox in the settingsForm() function which looks like:
I have set the default value to 1 in the getDefaultSettings() function. But the checkbox dont work, it keeps always 1. Could anyone tell me whats the problem with this, so i could submit a patch?
Comment #7
kitikonti CreditAttribution: kitikonti commentedSo after a few hours i figured it out, there happens some javascript magic in the form. I have a patch created for the 7.x-1.x-dev (also works in 7.x-1.5) which adds a checkbox in the display settings form, which by default is checked to show the count. I have not looked at the 7.x-2.x versions if it is also possible there because me is using the current recommended verison which is 7.x-1.5.
Comment #8
KelvinWong CreditAttribution: KelvinWong commentedGreat work kitikonti, #7 works. Would you able to make it compatible with search_api_ranges?
Many thanks
Comment #9
kitikonti CreditAttribution: kitikonti commentedmaybe because i am also using it, but i dont know when i have time for it
Comment #10
ssoulless CreditAttribution: ssoulless commented#7 should ber committed, Im working with it in a production site 1 month ago. and it works like a charm maybe the search_api_ranges compatibility can be another thread after this is commited
Comment #11
kitikonti CreditAttribution: kitikonti commentedi also think this should do it for now. for compatibility to search_api_ranges i think the most work has to be done in it's widget functions so this should be an extra issue for search_api_ranges anyway.
Comment #12
vegardjo CreditAttribution: vegardjo commentedI did this in a theme function in my themes template.php file:
..so basically wrapping the count in a span, and then hide or change it with CSS
Comment #13
thierrydallacroce#4 is a solution, at least until the patch is applied to 1.x.
However for clarification, the comment should reflect that it implements a hook_preprocess_HOOK for theme_facetapi_link_inactive().
Comment #14
cmseasy CreditAttribution: cmseasy commentedPatch 7 is working, I agry with #10
Comment #15
Scott Robertson CreditAttribution: Scott Robertson commentedThis patch did not work for me when I applied it to the latest version of 1.x. However, the patch here works:
https://www.drupal.org/node/2194423#comment-9779337
Marking this as a duplicate of #2194423
Comment #16
Scott Robertson CreditAttribution: Scott Robertson commented