Limit PageList Results

Permalink 1 user found helpful
Hi!

I try to find out how to limit the number of results returned by :

$list = new PageList();
$pages = $list->getResults();

I don't want a pagination just get, e.g, the latest page with 'news' template !

Any idea ?

thank you,
best,
moosh

moosh
 
moosh replied on at Permalink Reply
moosh
I find a solution :
$list->getQueryObject()->setMaxResults(1);

But don't understand why Concrete5 don't interface it directly!
We MUST getQueryObject() to solve this issue.

Another thing I saw, we can't sortByPublicDate in descending mode!
So, a little bit boring when we want e.g the 10 latest news with the latest in first position.

thanks!
moosh
Parasek replied on at Permalink Reply
Parasek
1. To get only some of pages, you need to use pagination.
https://documentation.concrete5.org/developers/working-with-pages/se...
scroll down to "Pagination"


2. You can sort pages in ascending mode
$list->sortByPublicDateDescending()
moosh replied on at Permalink Reply
moosh
1. yes but it's not what I expected..
With this method you get ALL matching results from database then split results in multiple pages.
This is a leak of performance when want to retrieve only one result (when having 150 pages e.g).

2. ahhhh yes! haven't seen it!