Does not work with Smart Date dates

Created on 29 December 2020, over 3 years ago
Updated 29 August 2023, 10 months ago

Problem/Motivation

This module does not work with date fields (i.e. unix timestamps(!)). D8 has dropped the support for such date fields, but Smart Date has introduced them back for performance reasons. On the other hand, Smart Date provides many advantages over the core date fields and contributed modules, like date range, date all day, recurring dates, in one Smart Date field.

Steps to reproduce

  • add a Smart Date field to your content
  • add content with smart date values
  • add a view for this content and add the smart date field (start) as a contextual filter
  • save the view
  • configure the date range to use this smart date field at admin/config/content/contextual-range-filter
  • go back to your view and test the date range filter

You will see that the generated sql is generated for a default date field, not for a unix timestamp.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Pepe Roni

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada chrisck

    Just reporting here that contextual_range_filter does work with Smart Date range field type. Make sure your contextual filters are enabled at /admin/config/content/contextual-range-filter

    Configure your smart date range field contextual filter as follows:
    When the filter value is NOT available

    • Provide default value
    • Type: PHP code
    if (isset($entity['node'])) {
      // Get the date range
      $start_date = $entity['node']->field_smartdate_range->value;
      $end_date = $entity['node']->field_smartdate_range->end_value;
      $range = $start_date . '--' . $end_date;
      return $range;
    }
    

    For lower limit range only:

    if (isset($entity['node'])) {
      // Get the date range
      $start_date = $entity['node']->field_smartdate->value;
      $range = $start_date . '--';
      return $range;
    }
    

    Hope this helps someone.

  • First commit to issue fork.
Production build 0.69.0 2024