dongtaotao19830418 2010-03-31 13:04
浏览 41
已采纳

在注入控制器Zend Framework中获取Params的问题

I have a layout 'profile'

<div>
    <div> $this->action(action1, controller1, module1)<div>
    <div> $this->layout()->content </div>
    <div> $this->action(someotheraction, soController,soModule );
</div

And the problem starts when I want to get the $request->Params() from the action1 , controller1 module1 , it is empty. I looked at the code of a helper Action , it does accept as a 4th parameter Params, but then I will have to set it somewhere in the layout - which is not good. Basically what are the recommendations of guru people that are pretty professional with zend Framework. Maybe I should do some work around or should change the concept of how I am injecting additional Controller(module) actions

  • 写回答

1条回答 默认 最新

  • dsfsfsfsfs55656 2010-03-31 13:45
    关注

    If you want to get the current Request object in the View, you can either inject it to the View from the controller or get it from the Front Controller via

    $request = Zend_Controller_Front::getInstance()->getRequest();
    

    The above is how the Action helper gets it itself.

    Any argument, including $params, set to the action method of Action Helper will be set to the current Request object before it is dispatched. The Request will go through the entire dispatch cycle again, which is slow and why the Action Helper is generally avoided. The Action Helper will return (but not output) the body of the Response.

    Not sure if that answers your question though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么