filter_hide_if_selected.inc in Facet API Bonus 7
FacetAPI Filter that removes the current facet if it has at least one item selected.
File
plugins/facetapi/filter_hide_if_selected.incView source
<?php
/**
* @file
*
* FacetAPI Filter that removes the current facet if it has at least one
* item selected.
*/
/**
* Plugin that hides the facet if it has an item already selected.
*/
class FacetapiFilterHideIfSelected extends FacetapiFilter {
/**
* Filters the items.
*/
public function execute(array $build) {
if (self::hasActiveItems($build)) {
return array();
}
return $build;
}
/**
* Check if any of the given facet items are selected.
*
* @param array $items
* The facet items.
* @return bool
*/
protected static function hasActiveItems($items) {
foreach ($items as $item) {
if ($item['#active']) {
return TRUE;
}
}
return FALSE;
}
}
Classes
Name![]() |
Description |
---|---|
FacetapiFilterHideIfSelected | Plugin that hides the facet if it has an item already selected. |