/** * Given a group of pages, render a simple <ul> navigation * * This is here to demonstrate an example of a simple shared function. * Usage is completely optional. * * @param PageArray $items * */ function renderNav(PageArray $items) { if (!$items->count()) { return; } echo "<ul class='nav'>"; // 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 echo "<li class='current'>"; } else { // otherwise just a regular list item echo "<li>"; } // markup for the link echo "<a href='{$item->url}'>{$item->title}</a> "; // if the item has summary text, include that too if ($item->summary) { echo "<div class='summary'>{$item->summary}</div>"; } // close the list item echo "</li>"; } echo "</ul>"; }