Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Prev/Next when ordered by DATE?

$
0
0

Hi, I have news articles ordered by their date, all working fine.

static $db = array(
   'Date' => 'Date',
   );

But on each article I want a next/previous buttons, but this function below isn't working for me, can anyone see where I've gone wrong?

function NextArticle() {
return DataObject::get("NewsArticle", "Date < ($this->Date)", "", "", "1");
}

function PreviousArticle() {
return DataObject::get("NewsArticle", "Date > ($this->Date)", "", "", "1");
}

On my ArticlePage template I'm using:

<% control PreviousArticle %><a class="prev" href="$Link"><</a><% end_control %>
<% control NextArticle %><a class="next" href="$Link">></a><% end_control %>


Posted to: Prev/Next when ordered by DATE? | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles