Jump to content

how to list children pages in chronological order ?


adrianmak
 Share

Recommended Posts

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

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');
}
  • Like 2
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...