public function FacetapiAjaxWidgetSelect::execute in Ajax facets 7.3
Same name and namespace in other branches
- 7 plugins/facetapi/ajax_widget_select.inc \FacetapiAjaxWidgetSelect::execute()
- 7.2 plugins/facetapi/ajax_widget_select.inc \FacetapiAjaxWidgetSelect::execute()
Implements FacetapiWidget::execute().
Transforms the render array into something that can be themed by theme_item_list().
Overrides FacetapiAjaxWidget::execute
See also
FacetapiWidgetLinks::setThemeHooks()
FacetapiWidgetLinks::buildListItems()
File
- plugins/
facetapi/ ajax_widget_select.inc, line 125 - The facetapi_links and facetapi_checkbox_links widget plugin classes.
Class
- FacetapiAjaxWidgetSelect
- Widget that renders facets as a list of clickable links.
Code
public function execute() {
$element =& $this->build[$this->facet['field alias']];
$items = $this
->buildListItems($element);
// If name is empty - use label.
if (empty($items['name'])) {
$facet = $this->facet
->getFacet();
$items['name'] = $facet['label'];
}
$select = [
'#type' => 'select',
'#title' => $this->build['#title'],
'#options' => $items['values'],
'#name' => rawurlencode($this->settings->facet),
'#attributes' => [
'data-facet-name' => rawurlencode($this->settings->facet),
'data-raw-facet-name' => $this->settings->facet,
],
'#theme' => 'ajax_facets_select',
'#disabled_items' => $items['#disabled_items'],
];
if (!empty($items['active_value'])) {
$select['#value'] = $items['active_value'];
}
// We cannot use drupal_html_id to save the same id for each facet.
$wrapper_id = $this->build['#attributes']['id'] . '-wrapper';
$element = [
'#markup' => '<div id="' . $wrapper_id . '">' . $this
->getResetLink() . render($select) . '</div>',
];
ajax_facets_add_ajax_js($this->facet);
}