Reputation: 185
i want to change my layout in the controller. (i know how to change per module, but do need to change certain pages on my application, hence my need to use the controller).
i have done the following but it still render the default layout.
'template_map' => array(
'layout/homepage' => __DIR__ . '/../view/layout/homePageLayout.phtml'
)
controller
$viewModel = new ViewModel();
$viewModel->setTemplate('layout/homepage');
return $viewModel;
i noticed from this answer that i am supposed to use this instead
$this->layout('layout/different');
but the author does not clarify how that is supposed to be used. i.e instead of setTemplate is their a setLayout.
Thank you in advance for kind help.
Upvotes: 0
Views: 86
Reputation: 185
i got the answer from this page.
all we need to do is this(same as above, accept that in the action we do the following)
public function someAction()
{
$this->layout("layout/homepage");
return new ViewModel(array(
));
}
Upvotes: 0