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条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog