facet_filter styling
libsys - October 8, 2007 - 23:40
| Project: | Solr |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
Description
To eliminate the redundant display of facets on search result pages, simply call array_unique on the facet items array.
So, this:
function theme_solr_facet_filters($type, $fq){
...
return theme('item_list', $items);
}becomes this:
function theme_solr_facet_filters($type, $fq){
...
return theme('item_list', array_unique($items));
}I will likely remove the links and add styling to selected facets within the facet display area to reinforce the search context as well. This is what I have done in the past. But array_unique will prevent redundant facets from being displayed either way.
Attaching a simple patch.
| Attachment | Size |
|---|---|
| solr.theme_facet_limit.patch | 0 bytes |

#1
see attached.
#2
Fixed, thanks for the patch. If you manage to add some decent styling for the chosen filters, that would be much appreciated.
#3
One thing I'd like to do w/facet output is to alter the text to my liking. What do you think about the idea of building a theme function to handle just this task? So, before displaying the facet link, for example, you call a text-altering theme:
$text = theme('facet_filter_text', $facet, $facet_arr[0], TRUE);$items[] = check_plain($text) . ' ' . l('x', "search/$type", array('class' => 'facet_filter'), sprintf('t=%s&fq=%s&df=%s', $_GET['t'], implode(' AND ', $filters), $_GET['df']));
facet_filter_text calls something like:
function theme_facet_filter_text($facet, $field, $labeled = FALSE){switch($field){
case 'year':
$facet_label = 'Year';
$facet = substr($facet, 0, 4); //get rid of the extra date/time formatting
break;
}
$output = ($labeled == TRUE)? $facet_label . ': ' . $facet : $facet;
return $output;
}
I think I'll be able to style the entire facet links via attributes in the item_list, but I need to actually change the text on display, hence this function. You can also call this in theme_solr_facet It did, however, occur to me that this theme function might be better suited as a node_hook though.
I guess it's food for thought anyway....
#4