Sort pagelist by parentID
Permalink
Hi,
I currently have a page list pulling in all the 'featured' pages onto the homepage using the 'is_featured' attribute.
Is there a way of sorting these pages by each page parentID.
My sitemap looks like this:
Cat 1 (id='140')
- page 1
- page 2 (featured)
- page 3
Cat 2 (id='141')
- page 1
- page 2
- page 3 (featured)
Cat 3 (id='142')
- page 1
- page 2 (featured)
- page 3
So id want the 3 featured pages to always by in oder of cat 1, cat 2 cat3 no matter which pages are marked as featured.
Hope this makes sense?
I currently have a page list pulling in all the 'featured' pages onto the homepage using the 'is_featured' attribute.
Is there a way of sorting these pages by each page parentID.
My sitemap looks like this:
Cat 1 (id='140')
- page 1
- page 2 (featured)
- page 3
Cat 2 (id='141')
- page 1
- page 2
- page 3 (featured)
Cat 3 (id='142')
- page 1
- page 2 (featured)
- page 3
So id want the 3 featured pages to always by in oder of cat 1, cat 2 cat3 no matter which pages are marked as featured.
Hope this makes sense?
Hi - You should be able to use this
$pagelist = new PageList(); $pagelist->sortBy('p1.cParentID', 'asc'); $featured = $pagelist->get();
Thank you that seems to work.
What is the p1.cParentID?
Thanks
What is the p1.cParentID?
Thanks
Its the reference to the column in the SQL that lives behind ->get() - you can access most things through there if needed.
$pagelist = new PageList();
$pagelist->filterByCollectionTypeID('10');
$pagelist->filterByAttribute('is_featured', 1, 'like');
$featured = $pagelist->get();