Commit be8b6bea authored by David Lesieur's avatar David Lesieur

Avoid showing empty references.

parent 91776e20
......@@ -53,8 +53,10 @@ function reference_facets_faceted_search_collect(&$facets, $domain, $env_id, $fi
if ((!isset($filter) || isset($filter['reference'][$field['field_name']])) && isset($arg->{$field['field_name']}) && is_array($arg->{$field['field_name']})) {
// Iterate through the field's multiple values.
foreach ($arg->{$field['field_name']} as $item) {
$category = new reference_facet_category($field, array_shift($item));
$facets[] = new reference_facet($field, array($category));
if (($value = array_shift($item)) != 0) { // Don't show empty references.
$category = new reference_facet_category($field, $value);
$facets[] = new reference_facet($field, array($category));
}
}
}
}
......@@ -73,6 +75,16 @@ class reference_facet extends cck_facet {
parent::cck_facet('reference', $field, $active_path);
}
function build_root_categories_query(&$query) {
$db_info = _cck_facets_db_info($this->_field);
$query->add_table($db_info['table'], 'vid', 'n', 'vid');
$main_column = array_shift($db_info['columns']);
$query->add_field($db_info['table'], $main_column['column'], $this->_field['field_name']);
$query->add_where($db_info['table'] .'.'. $main_column['column'] .' != 0'); // No empty references.
$query->add_groupby($this->_field['field_name']);
return TRUE;
}
function build_categories($results) {
$categories = array();
while ($result = db_fetch_object($results)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment