Hi experts,
I have created a news module to show articles on my website.
I want to show only news which are between my start- and end-date.
So I created:
$news = NewsArticle::get()->filter(array(
'StartDate:LessThanOrEqual' => date('Y-m-d'),
'EndDate:GreaterThanOrEqual' => date('Y-m-d')
))->sort(array('Date' =>'DESC'));
which doesn't work.
Silverstripe debug says:
[User Error] Uncaught InvalidArgumentException: ExactMatchFilter does not accept LessThanOrEqual as modifiers
GET /index.php/de/aktuelles/?showqueries=1
Line 20 in /Applications/XAMPP/xamppfiles/htdocs/framework/search/filters/ExactMatchFilter.php
Why is Silverstripe using the ExactMatchFilter ?
However
$news = NewsArticle::get()->filter(array(
'StartDate:LessThan' => date('Y-m-d'),
'EndDate:GreaterThan' => date('Y-m-d')
))->sort(array('Date' =>'DESC'));
works fine!
But doesn't give me the articles I do need.
Running SS 3.1.2
TIA Stephan