drob50257447 2015-03-10 07: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 09: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部