{{$first = TRUE;}}
{{$index =0;}}
{{foreach $roots as $id => $item}}
{{$index++;}}
{{if $preview or $item->canView()}}
{{$active = $preview ? $first : $item->activeOrChildActive();}}
{{if $active}}
{{\IPS\core\FrontNavigation::i()->activePrimaryNavBar = $item->id;}}
{{endif}}
{{$children = $item->children();}}
{{if $children }}
{$item->title()}
{{else}}
{{if $subBars && isset( $subBars[ $id ] ) && \count( $subBars[ $id ] )}}
{$item->title()} {{if $parent==0}}{{endif}}
{{else}}
{$item->title()}
{{endif}}
{{endif}}
{{endif}}
{{$first = FALSE;}}
{{endforeach}}