lehtu Posted January 21, 2015 Share Posted January 21, 2015 Look at my selector, my selector is amazing ( ): $favorites = $user->favorites->find("sort=title, private=0, start=".$start.", limit=".$limit); Favorites is Page field with settings: Multiple pages (PageArray). Private is an checkbox on every page which are listed on favorites. My test user has two(2) favorite pages. One public and one private. And it works great! Thanks bye! Wait.. I had a problem with this code: $favorites->getTotal(); I'm in the belief that this should return the amount of pages based on the selector excluding limit-selector. So the result should be one(1). But I'm getting two(2). Am I missing something or is this a bug? Even this one gives me two: $favorites = $user->favorites->find("sort=title, private=0"); echo $favorites->getTotal(); # 2 What I want is the total number of favorite pages. This of course works: $user->favorites->find('sort=title, private=0')->count(); But I would like to avoid making several finds if I could use ->getTotal. And why I can't do this? Because I'm using start/limit for pagination.. 1 Link to comment Share on other sites More sharing options...
kongondo Posted January 21, 2015 Share Posted January 21, 2015 Maybe it is this: http://processwire.com/api/arrays/page/ $p->getTotal() Get the total number of pages that were found from a $pages->find("selectors, limit=n") operation that led to this PageArray. The number returned may be greater than the number of pages actually in this PageArray instance, and is used for calculating pagination. Whereas $p->count() will always return the number of pages actually in this PageArray instance. 1 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