Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

SS3/blog sort order and pagination


Reply


913 Views

Avatar
prawnstar

Community Member, 127 Posts

15 September 2012 at 10:53am

Edited: 15/09/2012 12:26pm

I'm having an issue getting both sort order and limited pagination both working with latest blog module.

I've extended the BlogHolder and BlogEntry:
WorkHolder extends BlogHolder{}
WorkEntry extends BlogEntry{}

In my _config file I have:

BlogTree::$default_entries_limit=5;

And if I use this in my WorkHolder template, everything works fine. The list limits to 5 entries and the pager at the bottom of the posts works as expected:

<% loop BlogEntries %>

But...

If I change the sort order like this (or whatever I sort by):

<% loop BlogEntries.sort('Sort','ASC') %>

The order changes as expected, but the pagination no longer works. I get the pagination at the bottom of the blog list (e.g., '1 2 Next') but I also get every blog post on every page. So if I have 7 blog posts, I get all seven on page 1 and all seven on page 2.

I also tried doing something like this in my controller:

public function sortedChildren() {
$workentry = WorkEntry::get()->sort('Sort', 'ASC');
return $workentry;
}

And looping through the sortedChildren, but that has the same issue.

Can someone tell me if this is not possible or what I'm missing or point me in the right direction?

EDIT
Also, adding static $default_sort = 'Sort ASC'; to my WorkEntry class, ordered by SiteTree not SiteTree_Live.
Thanks,
Chris