使用 actionHelper 而不在输出中返回布局
我使用以下代码在我的一个视图中调用操作助手
echo $this->action('foo', 'bar');
barController 中的 fooAction 执行其操作并输出页面列表。然而,列表再次在输出中具有布局,这非常令人恼火。如果我在 fooAction 中禁用布局,这也会导致布局在实时端被完全禁用。
我很烦恼。我可以创建一个视图助手,并且有很多方法可以解决这个问题,但出于好奇,我想知道是否有人对此有解决方案。
I call an action helper in one of my views using the following code
echo $this->action('foo', 'bar');
The fooAction in the barController does its thing and outputs a list of pages. However, the list has the layout in the output again, which is mightily irritating. If I disable the layout in the fooAction, this causes layout to be completely disabled on the live side, as well.
I'm vexed. I could just create a view helper, and there are many ways around this, but out of curiousity I was wondering if anyone had a solution to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 ZF Action ViewHelper 参考指南
修改您的控制器以接受控制操作是否应禁用布局的参数。使用动作助手时,传递此控制标志。
旁注:使用 Action ViewHelper 被认为是不好的做法,因为它将再次经历整个调度过程,这会减慢您的应用程序的速度。如果可能,尝试直接访问模型。
From the ZF Reference Guide on Action ViewHelper
Modify your controller to accept a param that controls whether the action should disable the layout. When using the action helper, pass this control flag.
On a sidenote: using the Action ViewHelper is considered bad practise as it will go through the entire dispatch process again and this will slow down your app. If possible, try to access the model directly.