Reputation: 357
I have created two layouts: one for the login page and another for the rest of the site. After login I want to pass variables from login controller to zf2 layout, but not able to access.
How can i access the variables in layout created in a controller action?
Upvotes: 1
Views: 3891
Reputation: 1528
Some ways to do that in your controller:
$viewmodel = new ViewModel();
$viewmodel->setVariable('myvar', $myvar);
return $viewmodel;
$this->layout()->myvar = $myvar;
<?php echo $this->myvar; ?>
Upvotes: 6