function apachesolr_search_apachesolr_facets in Apache Solr Search 6
Same name and namespace in other branches
- 5.2 apachesolr_search.module \apachesolr_search_apachesolr_facets()
- 5 apachesolr_search.module \apachesolr_search_apachesolr_facets()
- 6.2 apachesolr_search.module \apachesolr_search_apachesolr_facets()
Implementation of hook_apachesolr_facets().
Returns an array keyed by block delta.
1 call to apachesolr_search_apachesolr_facets()
- apachesolr_search_block in ./
apachesolr_search.module - Implementation of hook_block().
File
- ./
apachesolr_search.module, line 493 - Provides a content search implementation for node content for use with the Apache Solr search application.
Code
function apachesolr_search_apachesolr_facets() {
$facets = array();
$facets['type'] = array(
'info' => t('Apache Solr Search: Filter by content type'),
'facet_field' => 'type',
);
$facets['uid'] = array(
'info' => t('Apache Solr Search: Filter by author'),
'facet_field' => 'uid',
);
$facets['language'] = array(
'info' => t('Apache Solr Search: Filter by language'),
'facet_field' => 'language',
);
$facets['changed'] = array(
'info' => t('Apache Solr Search: Filter by updated date'),
'facet_field' => 'changed',
);
$facets['created'] = array(
'info' => t('Apache Solr Search: Filter by post date'),
'facet_field' => 'created',
);
// A book module facet.
if (module_exists('book')) {
$facets['is_book_bid'] = array(
'info' => t('Apache Solr Search: Filter by Book'),
'facet_field' => 'is_book_bid',
);
}
// Get taxonomy vocabulary facets.
if (module_exists('taxonomy')) {
$vocabs = taxonomy_get_vocabularies();
foreach ($vocabs as $vid => $vocab) {
// In this case the delta and facet field are the same.
$delta = 'im_vid_' . $vid;
$facets[$delta] = array(
'info' => t('Apache Solr Search: Filter by taxonomy @name', array(
'@name' => $vocab->name,
)),
'facet_field' => $delta,
);
}
}
// Get CCK field facets.
$fields = apachesolr_cck_fields();
if ($fields) {
foreach ($fields as $name => $field) {
if (!empty($field['facets'])) {
// $delta can only be 32 chars, and the CCK field name may be this
// long also, so we cannot add anything to it.
$facets[$field['field_name']] = array(
'info' => t('Apache Solr Search: Filter by @field', array(
'@field' => $field['widget']['label'],
)),
'facet_field' => apachesolr_index_key($field),
);
}
}
}
return $facets;
}