简体   繁体   中英

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

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

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

试试这样

$this->layout()->setVariable('var', $data);

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'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM