Closed (fixed)
Project:
Facet API
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Oct 2011 at 14:47 UTC
Updated:
24 Oct 2011 at 15:30 UTC
Filters can easily remove items, but they just cannot add items because they don't have access to the map. Could we make that happen?
My use case is that I would like to implement a filter that adds items to a facet even if they return with zero items (designers tend to like this pattern those days).
Comments
Comment #1
cpliakas commentedHi Damien.
I am assuming you are referring to the "map callback", but please correct me if this assumption is wrong.
First, this module does support negative facets via a "Minumum facet count" setting of "0". See the issue posted at http://drupal.org/node/1219178#comment-4751838 as to whether or not this fits your use case.
If this isn't what you are looking to do, this could get a little tricky due to the concept of facet "realms". This allows you to display the same facet in multiple ways on the same page, for example as a list of clickable links in a block and as a form element somewhere else on the page. The trick here is that some processing is only done once for performance, whereas other items are processed per-realm such as filters and widgets. The overall application flow regarding facets is listed below:
One-time processing (see FacetapiFacetProcessor::process():
Per-realm processing (see FacetapiFacet::build())
After looking at the code I can see where it would be tough to add facet items via filters since you don't have any information about the facet being rendered. Therefore you can't even manually invoke the map callback. Maybe there should be some hook that gets fired to intercept the data after it is retrieved from the server? That way it would allow you to add items that would automatically be passed to the map callback. Any ideas are welcome.
Thanks,
Chris
Comment #2
damien tournoud commentedWhat I was looking for was the "Minumum facet count" setting of "0" :)
That said, having a standard hook that modifies the facet data returned by the server (probably in
FacetapiFacetProcessor::process()), would definitely be helpful in some cases.Comment #3
cpliakas commentedExcellent! Thanks for posting back. Based of this discussion, I added two new feature requests. One is regarding the hook, which is posted at #1304820: Implement a hook that can alter facet data after it is returned from the server. The other is to add a class to negative facets posted at #1304828: Add a CSS class identifying facets with no results so you can easily style them differently and facilitate easier implementation of the "Show faces with 0 results" checkbox as shown in this screenshot.
~Chris
Comment #4
cpliakas commentedUncovered a couple of bugs regarding the negative facet pattern:
#1305052: Negative facets not displayed when the mincount is 0
#1305058: Facet counts of 0 are not displayed