- Issue created by @mxh
When having a core Date field (not a timestamp, just "Date"), Views filter don't work for them when Smart Date is installed.
Expected: The view lists the created node, because it has value 2024-10-25 which is greater than 2024-10-24.
Actual result: The view lists nothing.
Taking a look into the built Views query gives a hint to the reason of the problem:
SELECT "node_field_data"."created" AS "node_field_data_created", "node_field_data"."nid" AS "nid"
FROM
{node_field_data} "node_field_data"
LEFT JOIN {node__field_mydate} "node__field_mydate" ON node_field_data.nid = node__field_mydate.entity_id AND node__field_mydate.deleted = '0'
WHERE ("node_field_data"."status" = '1') AND ("node_field_data"."type" IN ('page')) AND ((node__field_mydate.field_mydate_value >= 1672527600))
ORDER BY "node_field_data_created" DESC
LIMIT 11 OFFSET 0
The particular part ((node__field_mydate.field_mydate_value >= 1672527600)) cannot work because date values are being stored as strings, formatted as "Y-m-d". They are not being stored as timestamps.
Smart Date replaces the Views filter plugin by its own:
<?php
/**
* Implements hook_views_plugins_filter_alter().
*
* Replace the core date views filter with a version supporting granularity.
*/
function smart_date_views_plugins_filter_alter(array &$plugins) {
if (isset($plugins['date'])) {
$plugins['date']['class'] = 'Drupal\smart_date\Plugin\views\filter\Date';
$plugins['date']['provider'] = 'smart_date';
}
}
?>
.. whereas Smart Date's filter plugin extends from core date class Drupal\views\Plugin\views\filter\Date but usually this should be handled by Drupal\datetime\Plugin\views\filter\Date. The datetime class implementation also properly handles the "offset" option whereas Smart Date's implementation does not support it entirely.
TBD
TBD
Active
4.2
Code