<img id='logo' src='<?php 
echo $config->urls->templates;
?>
styles/images/logo.png' width='159' height='28' alt='ProcessWire' />
							</a>
						</h1>
					</li>
					<li class="toggle-topbar menu-icon">
						<a href="#"><span>menu</span></a>
					</li>
				</ul>
				<section class="top-bar-section">
					<ul class="right">

						<?php 
echo renderTopNav($homepage->children->prepend($homepage));
?>

						<?php 
if ($page->editable()) {
    ?>
						<li class='divider'></li>
						<li class='has-form'>
							<a class='tiny success button' href='<?php 
    echo $config->urls->admin . "page/edit/?id={$page->id}";
    ?>
'>Edit</a>
						</li>
						<?php 
}
?>
/**
 * Render items for placement in Foundation 'top-bar' recursive drop-down navigation
 *
 */
function renderTopNav(PageArray $items, array $options = array(), $level = 0)
{
    $defaults = array('tree' => 2, 'dividers' => true, 'repeat' => true);
    $options = array_merge($defaults, $options);
    $divider = $options['dividers'] ? "<li class='divider'></li>" : "";
    $page = wire('page');
    $out = '';
    foreach ($items as $item) {
        $numChildren = $item->numChildren(true);
        if ($level + 1 > $options['tree'] || $item->id == 1) {
            $numChildren = 0;
        }
        $class = '';
        if ($numChildren) {
            $class .= "has-dropdown ";
        }
        if ($page->id == $item->id) {
            $class .= "current ";
        }
        if ($item->id > 1 && $page->parents->has($item) || $page->id == $item->id) {
            $class .= "active ";
        }
        if ($class) {
            $class = " class='" . trim($class) . "'";
        }
        $out .= "{$divider}<li{$class}><a href='{$item->url}'>{$item->title}</a>";
        if ($numChildren) {
            $out .= "<ul class='dropdown'>";
            if ($options['repeat']) {
                $out .= "{$divider}<li><a href='{$item->url}'>{$item->title}</a></li>";
            }
            $out .= renderTopNav($item->children, $options, $level + 1);
            $out .= "</ul>";
        }
        $out .= "</li>";
    }
    return $out;
}