In each module in my application I'll have a main content section and a sidebar menu.
In my layout I have the following...
<div id="main" class="span8 listings">
<?php echo $this->content; ?>
</div>
<div id="sidebar" class="span4">
<?php echo $this->sidebar; ?>
</div>
My controllers all return a single ViewModel which specifies the content (see below) but how do I get it to also populate the sidebar?
public function detailsAction()
{
*some code to populate data*
$params = array('data' => $data);
$viewModel = new ViewModel($params);
$viewModel->setTemplate('school/school/details.phtml');
return $viewModel;
}
I've got a feeling I am doing something fundamentally wrong here.
You can include "sub templates" by using the partial view helper
In a controller you could use view models nesting and the layout plugin:
Now you just echo the variable in the layout script:
// Module.php add it is