I am using the Facet API for Solr search on my site.
The Facet API Bonus module provides a Rewrite items filter:
Filter "Rewrite Items": Filter plugin to rewrite labels or other data of the facet items by implementing a new dedicated hook_facet_items_alter (in a structured array, before rendering). Very handy to rewrite list field values or totally custom encoded facet values for user friendly output.
My site has three facets for boolean fields that have "Yes" or "No" options by default. Using this filter, I have rewritten them so that what is being selected is more clear:
function mymodule_facet_items_alter(&$build, &$settings) {
switch ($settings->facet) {
case 'field_friends':
foreach($build as $key => $item) {
if($item['#indexed_value'] == '1') {
$build[$key]['#markup'] = t("Wants friends");
}
else {
$build[$key]['#markup'] = t("Doesn't want friends");
}
}
break;
case 'field_money':
foreach($build as $key => $item) {
if($item['#indexed_value'] == '1') {
$build[$key]['#markup'] = t("Wants money");
}
else {
$build[$key]['#markup'] = t("Doesn't want money");
}
}
This works for the facets. But the problem is, if the user clicks Wants friends and Doesn't want money, then the Current Search block shows Yes and No (the unmodified facet values).
How can I rewrite the values of the facets show in the Current Search block too? As it is now, if a user selects multiple Yes and No values, they will have no idea what is actually being applied.