php - How do I pass data from the controller to the template view in ZF2 using Twig? -


i have problem passing data controller template view. no matter how try put data in view file, cannot access data i'm passing template.

i've uploaded test module here https://github.com/svenanders/twiglytest

controller:

 <?php    namespace twigly\controller;     use zend\mvc\controller\abstractactioncontroller;    use zend\view\model\viewmodel;    class twiglycontroller extends abstractactioncontroller     {      public function twiglyaction()     {            echo "go...";         // return array('version'=> \zend\version\version::version);          return new viewmodel(array(             'data' => array("test"=>"test2"),          ));      }    } 

view:

{% in data %}   <h2>{{ }}1</h2> {% endfor %} ...done 

result:

go...   ...done 

whereas expected receive data between go... , ...done

a bit of shot in dark but, can try 1 of following in view?

{% key,a in data %} <h2>{{ }}1</h2> {% endfor %} ...done 

or

{{ data['test'] }}. 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -