function apachesolr_search_apachesolr_facets in Apache Solr Search 6.2
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 apachesolr_search.module \apachesolr_search_apachesolr_facets()
Implementation of hook_apachesolr_facets().
Returns an array keyed by block delta.
2 calls to apachesolr_search_apachesolr_facets()
- apachesolr_date_apachesolr_prepare_query in contrib/
apachesolr_date/ apachesolr_date.module - Implementation of hook_apachesolr_prepare_query(). Adds sorts for enabled date facets to the sorting block.
- apachesolr_search_block in ./
apachesolr_search.module - Implementation of hook_block().
File
- ./
apachesolr_search.module, line 700 - 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('Node attribute: Filter by content type'),
'facet_field' => 'type',
);
$facets['uid'] = array(
'info' => t('Node attribute: Filter by author'),
'facet_field' => 'uid',
);
$facets['language'] = array(
'info' => t('Node attribute: Filter by language'),
'facet_field' => 'language',
);
$facets['changed'] = array(
'info' => t('Node attribute: Filter by updated date'),
'facet_field' => 'changed',
);
$facets['created'] = array(
'info' => t('Node attribute: Filter by post date'),
'facet_field' => 'created',
);
// A book module facet.
if (module_exists('book')) {
$facets['is_book_bid'] = array(
'info' => t('Book: Filter by Book'),
'facet_field' => 'is_book_bid',
'content_types' => variable_get('book_allowed_types', array(
'book',
)),
);
}
// 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('Taxonomy vocabulary: Filter by taxonomy @name', array(
'@name' => $vocab->name,
)),
'facet_field' => $delta,
'content_types' => $vocab->nodes,
'display_callback' => 'apachesolr_search_taxonomy_get_term',
);
}
}
// 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.
$placeholders = array(
'@field_type' => $field['field_type'],
'@field' => $field['widget']['label'],
'@field_name' => $field['field_name'],
);
$facets[$field['field_name']] = array_merge($field, array(
'info' => t('CCK @field_type field: Filter by @field (@field_name)', $placeholders),
'facet_field' => apachesolr_index_key($field),
'content_types' => $field['content_types'],
));
}
}
}
return $facets;
}