function facets_preprocess_block in Facets 8
Implements hook_preprocess_block().
Adds a class for the widget to the facet block to allow for more specific styling.
File
- ./
facets.module, line 130 - Contains facets.module.
Code
function facets_preprocess_block(&$variables) {
if ($variables['configuration']['provider'] == 'facets') {
// Hide the block if it's empty.
if (!empty($variables['elements']['content'][0]['#attributes']['class']) && in_array('facet-hidden', $variables['elements']['content'][0]['#attributes']['class'])) {
// Add the Drupal class for hiding this for everyone, including screen
// readers. See hidden.module.css in the core system module.
$variables['attributes']['class'][] = 'hidden';
}
if (!empty($variables['derivative_plugin_id'])) {
$facet = Facet::load($variables['derivative_plugin_id']);
$variables['attributes']['class'][] = 'block-facet--' . Html::cleanCssIdentifier($facet
->getWidget()['type']);
}
}
}