I currently achieve multi-tier menus in my MVC framework (Symfony specifically but this pattern should transfer) by setting the rendering in a separate include (component in Symfony terms) that recursively calls itself to render each tier. The include's controller requests the current tier from the model and then passes it to the view. The include's view renders each returned element and calls the include again to print all child elements if available, passing in the current element's ID to query off of the parent value in the model.
As far as conditioning the display of the menu I would leave that in your top level view since it sounds like it's view-specific.
Model
You should be good with Doctrine's findByX methods here to query for the current tier's items. The field in my schema is called parent
so I would use findByParent
.
Include's Controller
$items = Doctrine::getTable('TopMenuItems')->findByParent( isset($parent) ? $parent : null) ) // null for initial call to grab top-tier elements, recursion should pass in new parent for children
Include's View
<?php foreach($items as $item) : ?>
// echo HTML element for nav item
<?php $parent = $item['parent']; include('top_menu.php'); // call nav again to print this item's children ?>
<?php endforeach; ?>
Main View
<?php if($user->wantsTopMenu()) : ?>
<?php include('top_menu.php'); ?>
<?php endif; ?>
Hope that helps.