adrianmak Posted January 7, 2016 Share 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 ? Link to comment Share on other sites More sharing options...
adrian Posted January 7, 2016 Share 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 Link to comment Share on other sites More sharing options...
adrianmak Posted January 7, 2016 Author Share 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); 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