I have this function:
public function LatestArticles() {
return $this->Children()
->filter('PublicationDate:LessThanOrEqual', SS_Datetime::now())
->sort('PublicationDate','desc');
}
It's not outputting anything at all. If I switch it to this:
public function LatestArticles() {
return ArticlePage::get()
->filter('PublicationDate:LessThanOrEqual', SS_Datetime::now())
->sort('PublicationDate','desc');
}
It outputs of my ArticlePages, but that (obviously) includes all ArticlePages site wide, not just the Children ArticlePages.
If I change the code to this:
public function LatestArticles() {
return $this->Children()
->sort('PublicationDate','desc');
}
That outputs all my children ArticlePages but that includes articles that have a publication date later than today.
It seems to me that I'm maybe not using the filter function correctly. Where am I going wrong?