views_faceted_filters_js-0.0.18/modules/views_faceted_filters_js_subitem_example/views_faceted_filters_js_subitem_example.module

modules/views_faceted_filters_js_subitem_example/views_faceted_filters_js_subitem_example.module
<?php

/**
 * @file
 * Primary module hooks for Views faceted filters js module.
 */

/**
 * Alters the facet definitions.
 *
 * Alters the facet definitions, provided to csff.js from the
 * view style settings.
 *
 * @param array $facets
 *   The facets definition.
 * @param array $variables
 *   All variables available (not modifiable).
 */
function views_faceted_filters_js_subitem_example_views_faceted_filters_js_facets_alter(array &$facets, array $variables) {
  // Add a further facet definition, which
  // should / can not be defined in Views UI Style settings:
  $facets[] = [
    'id' => 'color',
    'title' => 'Color',
    'description' => 'Filter by color',
    'count_show' => FALSE,
    'values_sort' => 'value',
    'values_sort_direction' => 'asc',
    'multivalue_separator' => '|',
    'weight' => 99,
  ];

  $facets[] = [
    'id' => 'size',
    'title' => 'Size',
    'description' => 'Filter by size',
    'count_show' => FALSE,
    'values_sort' => 'count',
    'values_sort_direction' => 'desc',
    'multivalue_separator' => '|',
    'weight' => 100,
  ];

  // The corresponding data must be added to the view individually, for example
  // by using a "Global > Custom text" views field or https://www.drupal.org/project/views_field_view
  // The expected subitem data structure can for example be like this:
  // You may copy this into a "Custom text with token" field to see the facets.
  // Do NOT expose this field as facet. The hook above will prepare the facets for this.
  // And the values will be determined fom DOM automatically.
  /*
  ~~~
  <div class="csff-subitem" data-csff-facet-color--value="Red" data-csff-facet-size--value="M">Red, M</div>
  <div class="csff-subitem" data-csff-facet-color--value="Red" data-csff-facet-size--value="L">Red, L</div>
  <div class="csff-subitem" data-csff-facet-color--value="Red" data-csff-facet-size--value="XL">Red, XL</div>
  <div class="csff-subitem" data-csff-facet-color--value="Blue" data-csff-facet-size--value="XL">Blue, XL</div>
  <div class="csff-subitem"><span data-csff-facet-color--value="Blue">Blue</span>, <span data-csff-facet-size--value="XXL">XXL</span></div>
  ~~~
  */
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc