PageList's get() function's limit doesn't work
Permalink
I'm trying to do something as simple as:
Unfortunately, I'm getting all the pages that have the is_featured attribute instead of just 4. What am I missing here?
$home_slider = Core::Make('PageList'); $home_slider = new PageList(); $home_slider->sortByPublicDateDescending(); $home_slider->filterByAttribute("is_featured",1); $pages = $home_slider->get(4); foreach($pages as $page): // bla bla endforeach;
Unfortunately, I'm getting all the pages that have the is_featured attribute instead of just 4. What am I missing here?
Ok, this is most likely NOT the way to do it as I ended up having a MASSIVE CPU usage - like 20% from a huge octa-core CPU by serving 5 simple (ish) page lists from a website with <100 pages. With caching turned on.
There's also the memory issue which basically is that 512MB of memory_limit sometimes aren't enough.
Any input would be much appreciated.
Edit: there's something I seem to have missed - setItemsPerPage:
It's likely the answer to my question but I'll wait until someone confirms.
There's also the memory issue which basically is that 512MB of memory_limit sometimes aren't enough.
Any input would be much appreciated.
Edit: there's something I seem to have missed - setItemsPerPage:
$home_slider = new \Concrete\Core\Page\PageList(); $home_slider->filterByAttribute("is_featured",1); $home_slider->sortByPublicDateDescending(); $home_slider->setItemsPerPage(4); $pagination = $home_slider->getPagination(); $pagination->setMaxPerPage(4)->setCurrentPage(1); $results = $pagination->getCurrentPageResults();
It's likely the answer to my question but I'll wait until someone confirms.
But how do I define an offset like in the old get() method? setCurrentPage(2)? Is this the correct way to do it? This makes much less sense than 5.6...