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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Pepe Roni created an issue.

benjarlett’s picture

I need this too.. darn.

chrisck’s picture

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.

gge made their first commit to this issue’s fork.