adrianmak Posted January 7, 2016 Posted January 7, 2016 I have following code segment in a template, which list all child pages of current page. if($page->hasChildren) { $content .= renderNav($page->children, array('ul'=>'article-index list clearfix', 'li'=>'article-index__item'), 'post_date'); } Currently, child pages are listed in the order of creation. The template used by child has a date field. How to order the child by this date field ?
adrian Posted January 7, 2016 Posted January 7, 2016 Use sort in the children method like this, assuming the date field is actually "date": if($page->hasChildren) { $content .= renderNav($page->children("sort=date"), array('ul'=>'article-index list clearfix', 'li'=>'article-index__item'), 'post_date'); } 2
adrianmak Posted January 7, 2016 Author Posted January 7, 2016 Use sort in the children method like this, assuming the date field is actually "date": if($page->hasChildren) { $content .= renderNav($page->children("sort=date"), array('ul'=>'article-index list clearfix', 'li'=>'article-index__item'), 'post_date'); } That is more simple than another code segment I found on another post something like $childpages = $pages->find("has_parent=$page->id, sort=post_date"); $content .= renderNav($childpages);
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