- Issue created by @oliverpolden
- π¬π§United Kingdom oliverpolden
This is a patch to simply allow year(curdate()) in the year field. This would need a bit more work to at a minimum add some help text to that effect but at least this works.
- Status changed to Needs work
9 months ago 11:55am 24 February 2024 - π§π·Brazil igorgoncalves
@oliverpolden i got the same issue as you but end up working without no patch.
you can just use the regular option "A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred."and set the field value as: Y
- πͺπΈSpain ady1503
@oliverpolden i got the same issue but your patch not working VersiΓ³n de Drupal 10.2.6.
It would be correct for this module to have the option to activate the current year automatically if none is indicated or it is left empty.
Thank you.
- πͺπΈSpain ady1503
@oliverpolden here is working example for year filter node
function yourmodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { // make sure we're altering the correct view if ($view->storage->get('id') === 'your_view' && $view->current_display === 'your_display') { $currentYear = date('Y'); $query->addWhereExpression(0, "EXTRACT(YEAR FROM FROM_UNIXTIME(node_field_data.created)) = :year", [':year' => $currentYear]); } }
node_field_data.created is for created year