Jump to content

Recommended Posts

Posted

Hi.

This code is not working. How can I render pagination in Modules?

public function ___execute() {
    ......
    $news_list = $this->pages->find('template=news-page,limit=1,sort=-created');
    ......
    $out .= $news_list->renderPager();
    ......
   }
Posted

I see it's a process module for an admin page so the template would be 'admin' and it already has page numbers active. So my first suggestion still holds true I think.

Little OT: the selector should first sort and then limit as youll get different results.

  • Like 1
Posted

Repeating what Soma already said, but limit has to be > 1 in order for pagination to work. Will soon remove that limitation, but until then I suggest using a limit=2 and adjusting the math a little in the API calls to get the pagination working.

Posted

Little OT: the selector should first sort and then limit as youll get different results.

A little more OT, but I have to disagree with what you're saying. When using find() the order of sort and limit doesn't matter at all if they're both used at once. The database query would be like '... ORDER BY xyz LIMIT nnn' either way. And if find() was used for an already existing PageArray, this would still hold true - works perfectly both ways (sort is executed first).

But, if the sort and limit were done separately, it's a different story (left other selectors out):

find('sort=-created, limit=1')

equals to

find('limit=1, sort=-created')

..but..

find('sort=-created')->find('limit=1')

does not equal to (unless there's only one item in the array we're dealing with)

find('limit=1')->find('sort=-created')
  • Like 1
Posted

Thanks Nik for sorting this out. You're right actually. But I remember some case where it wasn't like this and the order would matter, but that's half year ago, so probably messed up or something has changed since then.

Posted

Soma I believe something was fixed recently in this area so you're not going crazy ;)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...