public function FacetapiAjaxWidgetSelect::execute in Ajax facets 7
Same name and namespace in other branches
- 7.3 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().
See also
FacetapiWidgetLinks::setThemeHooks()
FacetapiWidgetLinks::buildListItems()
File
- plugins/
facetapi/ ajax_widget_select.inc, line 133 - 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 = array(
'#type' => 'select',
'#title' => $this->build['#title'],
'#options' => $items['values'],
'#id' => 'ajax-facets-selectbox-' . str_replace('_', '-', $this->settings->facet),
'#name' => urlencode($this->settings->facet),
'#attributes' => array(
'data-facet' => urlencode($this->settings->facet),
),
);
if (!empty($items['active_value'])) {
$select['#value'] = $items['active_value'];
}
$reset_link = '';
if (!empty($this->settings->settings['selectbox_show_reset_link']) && $this->settings->settings['selectbox_show_reset_link']) {
$reset_link = '<a class="reset-link" href="#">' . t('Reset filter') . '</a>';
}
$element = array(
'#markup' => '<div class="facet-wrapper-selectbox ' . $this->build['#attributes']['id'] . '">' . $reset_link . render($select) . '</div>',
);
}