content_taxonomy_facets.module in Content Taxonomy 5
File
content_taxonomy_facets.module
View source
<?php
require_once './' . drupal_get_path('module', 'cck_facets') . '/cck_facets.inc';
function content_taxonomy_facets_cck_facets_collect(&$facets, $field, $domain, $env_id, $arg = NULL) {
if ($field['type'] == 'content_taxonomy') {
switch ($domain) {
case 'all':
$facets[] = new cck_facet($field);
break;
case 'text':
if ($tid = search_query_extract($arg, $field['field_name'])) {
if (is_numeric($tid)) {
$category = new cck_facet_category($field, $tid);
$facets[] = new cck_facet($field, array(
$category,
));
}
$arg = search_query_insert($arg, $field['field_name']);
}
break;
case 'node':
if (isset($arg->{$field['field_name']}) && is_array($arg->{$field['field_name']})) {
foreach ($arg->{$field['field_name']} as $item) {
$value = array_shift($item);
if (is_numeric($value)) {
$category = new cck_facet_category($field, $value);
$facets[] = new cck_facet($field, array(
$category,
));
}
}
}
break;
}
}
return $arg;
}