I'm running into issue trying to sort the renderNav function. Here is the default code...
function renderNav(PageArray $items) {
// $out is where we store the markup we are creating in this function
$out = '';
// cycle through all the items
foreach($items as $item) {
// render markup for each navigation item as an <li>
if($item->id == wire('page')->id) {
// if current item is the same as the page being viewed, add a "current" class to it
$out .= "<li class='current'>";
} else {
// otherwise just a regular list item
$out .= "<li>";
}
// markup for the link
$out .= "<a href='$item->url'>$item->title</a>";
// if the item has summary text, include that too
if($item->summary) $out .= "<div class='summary'>$item->summary</div>";
// close the list item
$out .= "</li>";
}
// if output was generated above, wrap it in a <ul>
if($out) $out = "<ul class='nav'>$out</ul>\n";
// return the markup we generated above
return $out;
}
I'm wanting it to order the pages from newest to oldest. The code above list oldest to newest. Can anyone help me out with this?