public function renderMenu($topNode = 'root', $includeTopNode = false)
{
$menuContent = "";
try {
$topNode = $this->getMenuItem($topNode);
$menuBranch = $this->getMenuBranch();
$variables = $this->getVariables($topNode);
$menuContent = $this->replaceVars($this->MENU_HEADER, $variables);
if ($includeTopNode) {
$menuContent .= $this->renderMenuItem($topNode, $variables, $menuBranch);
} else {
$children = $topNode->children;
foreach ($children as $child) {
$menuContent .= $this->renderMenuItem($child, $variables, $menuBranch);
}
}
$menuContent .= $this->replaceVars($this->MENU_FOOTER, $variables);
} catch (\Exception $ex) {
$menuContent = "<!-- Failed to render menu -->";
}
return view($this->MENU_PARTIAL_VIEW, compact('menuContent'));
}