drob50257447 2015-03-10 15:43
浏览 23
已采纳

如何在Zend Framework 2中包含多个动作和控制器

I would like to include multiple views within a view in ZF2. I read this link: http://framework.zend.com/manual/current/en/modules/zend.view.quick-start.html

but there is a problem. In this way, I have to pass the values that are within a view, like this:

$secondView = new ViewModel (array('var1' => $var1 ......));

In this mode the controller and second action are bypassed. Is there a way to include a view without bypassing them? I would like variables to be passed from the second action controller, like an include php statement

  • 写回答

2条回答 默认 最新

  • dryl34156 2015-03-10 17:43
    关注

    If I understood correctly your question, I think that what you're asking is not possible.

    My suggestion would be to move the retrieval of the data you need for the secondView somewhere else, away from the controller, and call it both from the second controller and form the first controller to pass them to the secondView.

    If you really want to go on with your approach, the only possibility I see is to use javascript and ajax calls to retrieve the partials you need in your view

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?