In #2479399: Facet API integration still allows filtering on access-controlled/unloadable entities, we want to hide facet filters that correspond with inaccessible/non-existent taxonomy terms. This would be easily possible via the map callback, by just letting an explicit label of FALSE mean that the filter should be hidden. However, this possibility doesn't yet exist in the Facet API, as far as I can see.

Do you think it would be possible to add this feature?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Status: Active » Needs review
FileSize
680 bytes

The attached patch would implement this.

stefan.r’s picture

I can confirm this patch would be useful in solving the linked issue!

pwolanin’s picture

is FALSE better than NULL?

Just wondering if FALSE is a valid value for boolean facets?

stefan.r’s picture

FALSE can actually be used for boolean facets so let's go with NULL instead?

pwolanin’s picture

That seems less likely to cause issues, and setting to NULL is pretty clear in terms of intent?

stefan.r’s picture

OK good, in manual testing there seemed to be no issues with this.

drunken monkey’s picture

Just wondering if FALSE is a valid value for boolean facets?

I don't think that makes sense, no, since we're not talking about the values, but about the labels. And a non-string label doesn't make any sense – instead of FALSE, you can still use '' for the same effect (though I don't think many people will want that).
We picked FALSE, I think, because it feels more like an explicit "No!" instead of an "I don't care" which NULL seems to imply (in my eyes – highly subjective of course).
But of course, I'm fine with either. I just don't think there will be technical problems with either option.

stefan.r’s picture

I think currently in boolean facets the label can have the value FALSE in the map, which will get translated to 'no' upon printing to screen... whereas the previous patch would make any "no"s disappear altogether?

drunken monkey’s picture

As said, labels are inherently strings, not booleans. I don't think there's anywhere where anyone sets FALSE as a label. Please try to reproduce the problem and/or find code supporting your claim before just using it as an argument based upon pure conjecture. (Also, where would the magic be that automatically translates FALSE to 'no' when printing?)

But, as said, I'm fine with either solution. If you both like NULL better, please just commit that version and we'll change the patch in #2479399: Facet API integration still allows filtering on access-controlled/unloadable entities accordingly.
In any case, thanks for your feedback, Peter! (But you don't have commit access either, right?)

pwolanin’s picture

I have had commit for a long while https://www.drupal.org/node/808232/maintainers

pwolanin’s picture

Status: Needs review » Fixed

Does this need to be ported to 8.x?

  • pwolanin committed 9c8713f on 7.x-1.x authored by stefan.r
    Issue #2545130 by drunken monkey, stefan.r: Allow the map callback to...
drunken monkey’s picture

Ah, sorry! You aren't listed on the project page, and I thought that lists all the people with commit access. (I can't access the "Maintainers" tab and this list mentions everyone who contributed a patch, too.) Then I guess there's no way to see who has commit access for non-maintainers? Strange …

Anyways, thanks for committing!
And no, the D8 version is a) a complete re-write and b), as far as I know, not very far yet, so we don't need to port this.

Status: Fixed » Closed (fixed)

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