You are here

function facetapi_widget_links in Facet API 6

Builds items as array of links that can be passed to theme_item_list().

Parameters

&$build: The facet's render array.

&$key: A string containing the key the facet's render array will be appended to.

&$settings: An array containing the JavaScript settings.

1 call to facetapi_widget_links()
facetapi_widget_link_checkboxes in ./facetapi.widget.inc
Renders facets as links with checkboxes, useful for facets using the OR operator.
1 string reference to 'facetapi_widget_links'
facetapi_facetapi_widget_info in ./facetapi.module
Implementation of hook_facetapi_widget_info().

File

./facetapi.widget.inc, line 18
Widget callbacks and building functions.

Code

function facetapi_widget_links(array &$build, &$key, &$settings) {
  drupal_add_js(drupal_get_path('module', 'facetapi') . '/js/facetapi.block.js');

  // Captures facet information for code readability,
  $facet_name = $build['#facet']['name'];
  $field_alias = $build['#facet']['field alias'];

  // Sets key to facet name since facets shoudln't be grouped by alias.
  $key = $build['#facet']['name'];

  // Adds theme functions to each item dependent on whether it is active or not.
  facetapi_theme_hooks_set($build[$field_alias], 'facetapi_link_active', 'facetapi_link_inactive');

  // Converts the array to something that can be read by theme_item_list().
  $build['#theme'] = 'facetapi_item_list';
  $build[$field_alias] = facetapi_item_list_build($build[$field_alias]);

  // Adds "soft limit" to the javascript settings.
  $searcher = $build['#adapter']
    ->getSearcher();
  $limit = facetapi_setting_get('soft_limit', $searcher, $build['#realm_name'], $build['#facet']['name']);
  $settings['limit'] = NULL === $limit ? 10 : $limit;
}