Khan Posted December 23, 2012 Share Posted December 23, 2012 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(); ...... } Link to comment Share on other sites More sharing options...
Soma Posted December 23, 2012 Share Posted December 23, 2012 Limit=1 doesnt yet work. Also make sure page mumbers are turned on on template url settings. Link to comment Share on other sites More sharing options...
Khan Posted December 23, 2012 Author Share Posted December 23, 2012 this is not template file this is module file. Link to comment Share on other sites More sharing options...
Soma Posted December 23, 2012 Share Posted December 23, 2012 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. 1 Link to comment Share on other sites More sharing options...
ryan Posted December 23, 2012 Share Posted December 23, 2012 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. Link to comment Share on other sites More sharing options...
Khan Posted December 23, 2012 Author Share Posted December 23, 2012 Thanks 1 Link to comment Share on other sites More sharing options...
nik Posted December 29, 2012 Share Posted December 29, 2012 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') 1 Link to comment Share on other sites More sharing options...
Soma Posted December 30, 2012 Share Posted December 30, 2012 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. Link to comment Share on other sites More sharing options...
Pete Posted December 30, 2012 Share Posted December 30, 2012 Soma I believe something was fixed recently in this area so you're not going crazy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now