how to call and pass array data to layout from controller in zend 2?

69 Views Asked by At

Here is my Code, how to and pass data from controller to layout

   $arr = array();
   $arr['layout'] = 'example';
   $this->layout()->calllayout = $arr;
2

There are 2 best solutions below

0
D Coder On

try like this

$this->layout()->setVariable('var', $data);
0
Maulik Patel On

Before ViewModel Write serVariable by $this->layout() like:

$arr = array();
$arr['layout'] = 'example';
$this->layout()->setVariable('variableName', $arr);

and Access it like :

echo $this->variableName['layout'];