Jump to:

1856 Posts in 1610 Topics by 562 members

Blog Module

SilverStripe Forums » Blog Module » SS3/blog sort order and pagination

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 844 Views
  • prawnstar
    Community Member
    116 Posts

    SS3/blog sort order and pagination Link to this post

    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:


    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 %>


    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?

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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.