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.
Anyone know how to change the display of a boolean field facet from "true" to "yes"? Thanks!
Comment | File | Size | Author |
---|---|---|---|
#10 | 1757470-10.patch | 1.35 KB | pwolanin |
#9 | apachesolr-booleanallowedvalues-1757470-9.patch | 1.19 KB | j0rd |
#7 | apachesolr-booleanallowedvalues-1757470-7.patch | 1.17 KB | j0rd |
#6 | apachesolr-booleanallowedvalues-1757470-6.patch | 1.17 KB | j0rd |
#4 | apachesolr-booleanallowedvalues-1757470-3.patch | 789 bytes | j0rd |
Comments
Comment #1
Nick_vhThis is a facet api question. The answer should be to define a map_callback for the specific facet.
Take a look at facetapi_map_bundle to see how that works
Comment #2
chrisrikli CreditAttribution: chrisrikli commentedHere's how I did it:
It's a little crude and should be refined to catch all boolean fields and map the values assigned in the field's user interface. But it works.
Comment #3
j0rd CreditAttribution: j0rd commentedThis is actually a bug in apachesolr, as the code which is written isn't working as the programmer expected it to IMHO. There's a slight oversight which is causing this issue.
When a boolean facet in ApacheSolr get's returned, the values are "true" & "false".
When "allowed_values" for a boolean Drupal field are stored, they are keyed as "0" and "1".
This means when we're trying to get the human readable values, we're comparing mix matched types....and we find nothing, then display the solr value.
I'm pretty sure this is a slight over sight and in fact a bug.
Here's a patch which resolves the issue.
Comment #4
j0rd CreditAttribution: j0rd commenteddouble post sorry.
Comment #5
Nick_vhLooks reasonable.
I just don't like this small programming manner. It makes it complex to read. Certainly if it is used inside the id of an array value.
Comment #6
j0rd CreditAttribution: j0rd commentedRemoved the ternary operator.
Comment #7
j0rd CreditAttribution: j0rd commentedPatch above is wrong. Has a typo. This one is correct.
Comment #9
j0rd CreditAttribution: j0rd commentedAnother typo. One last time.
Comment #10
pwolanin CreditAttribution: pwolanin commentedfixed if() to a ternary and improved code comment.
Comment #11
pwolanin CreditAttribution: pwolanin commentedcommitted to 7 and 6