function facetapi_facet_status_set in Facet API 6
Sets the enabled/disabled status of a facet. It is recommended that the facetapi_facet_enable() and facetapi_facet_disable() functions are used in favor of calling this function directly.
Parameters
$searcher: A string containing the machine readable name of the searcher module.
$realm_name: A string containing the machine readable name of the realm. Passing NULL will take action on the facet in all realms.
$facet_name: A string containing the machine readable name of the facet.
$enabled: A boolean flagging whether the facet is enabled.
2 calls to facetapi_facet_status_set()
- facetapi_facet_disable in ./
facetapi.module - Disables a facet in the passed realm.
- facetapi_facet_enable in ./
facetapi.module - Enables a facet in the passed realm.
File
- ./
facetapi.module, line 761 - An abstracted facet API that can be used by various search backens.
Code
function facetapi_facet_status_set($searcher, $realm_name, $facet_name, $enabled) {
$realm_names = NULL === $realm_name ? array_keys(facetapi_realms_get()) : array(
$realm_name,
);
foreach ($realm_names as $realm_name) {
// Gets current variable, toggles status for the facet, sets the variable.
$facets = (array) facetapi_setting_get('facet_status', $searcher, $realm_name);
$facets[$facet_name] = $enabled ? $facet_name : 0;
facetapi_setting_set('facet_status', $facets, $searcher, $realm_name);
// Clears the facet status cache.
$cid = 'facetapi:facets:' . $searcher . ':';
if (NULL !== $realm_name) {
$cid .= $realm_name . ':';
}
cache_clear_all($cid, 'cache', TRUE);
}
}