Nicholas Cheek

LITTLE ROCK WEB DEVELOPER

Find each child page to dynamically create a menu

// Create the top navigation list by listing the children of the homepage. 
// If the section we are in is the current (identified by $page->rootParent)
// then note it with <a class='on'> so we can style it differently in our CSS. 
// In this case we also want the homepage to be part of our top navigation, 
// so we prepend it to the pages we cycle through:

$homepage = $pages->get("/"); 
$children = $homepage->children;
$children->prepend($homepage); 
$ct = 00;

foreach($children as $child) {
	$class = $child === $page->rootParent ? " class='on'" : '';
	echo "<li> <a$class href='{$child->url}'>{$child->title}</a></li>";
}

LITTLE ROCK WEB DEVELOPER

Living the dream.

nick@nicholascheek.com