Facets Exposed Filters - DateItemProcessor not working

Created on 12 November 2024, 3 months ago

Problem/Motivation

When recreating my facets from "normal" facets to the new and improved Facets Exposed Filters I ran into an issue with date facets. I added a indexed field with a date in it and I want to show only the year as granularity. However, whatever setting I choose (year, month, day) it will always show the timestamp in the facet.

Steps to reproduce

Index a date field with type "Date". Create a exposed facet in a view for that field, and enable "Date item processor".

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands fabianderijk Alphen aan den Rijn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fabianderijk
  • 🇧🇪Belgium StryKaizer Belgium

    For now, "facets exposed filters" uses hardcoded query_type_text.
    We need to add querytype plugins support.

    Attached is a patch which adds support for different querytypes (e.g. date & range)

    This patch breaks showing active facet items with 0 results, as the facet results now act similar to how facet block facet results act.
    We probably want to ensure active facet items with 0 items are always visible, both for the old "facet blocks" way, as for "facets exposed filters". This is even more important for "facets exposed filters", as we do not control the url ourself, and views wont remember non-existing elements.

  • 🇳🇱Netherlands fabianderijk Alphen aan den Rijn

    This patch seems to work great! Thanks.

    • strykaizer committed db469e4c on 3.0.x
      Issue #3487002 by strykaizer: Facets Exposed Filters - Support different...
  • This seems related, but I'm not entirely sure. Let me know if it would be better to open a new issue.

    When I attempt to enable the Range Slider processor/widget on facets_exposed_filter, I encounter this error:

    ```
    TypeError: Cannot access offset of type string on string in Drupal\facets\Entity\Facet->getWidgetInstance() (line 395 of modules/contrib/facets/src/Entity/Facet.php).
    Drupal\facets_range_widget\Plugin\facets\processor\SliderProcessor->postQuery(Object) (Line: 144)
    Drupal\facets_exposed_filters\Plugin\views\filter\FacetsFilter->valueForm(Array, Object) (Line: 969)
    Drupal\views\Plugin\views\filter\FilterPluginBase->buildExposedForm(Array, Object) (Line: 103)
    Drupal\views\Form\ViewsExposedForm->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('views_exposed_form', Object) (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm('\Drupal\views\Form\ViewsExposedForm', Object) (Line: 134)
    Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 115)
    facets_exposed_filters_views_post_execute(Object)
    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'facets_exposed_filters') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('views_post_execute', Object) (Line: 416)
    Drupal\Core\Extension\ModuleHandler->invokeAll('views_post_execute', Array) (Line: 1450)
    Drupal\views\ViewExecutable->execute(NULL) (Line: 1469)
    Drupal\views\ViewExecutable->render() (Line: 131)
    Drupal\views\Plugin\views\display\Block->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('block_2', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array) (Line: 61)
    Drupal\views\Plugin\Block\ViewsBlock->build() (Line: 240)
    Drupal\block_field\Plugin\Field\FieldFormatter\BlockFieldFormatter->preRender(Array)
    ...
    ```

  • 🇧🇪Belgium StryKaizer Belgium

    Please open a new issue for this :)

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪
Production build 0.71.5 2024