Zend Framework 中如何从视图调用视图?

发布于 2024-09-07 02:11:19 字数 201 浏览 13 评论 0原文

我需要从视图内部渲染视图。

为了方便起见,我将它们称为块。

我有 5 个控制器,每个控制器都有一个名为 BlockAction() 的操作,并且它显示来自该控制器的一些信息。

在整个网站的索引页面中,我需要调用所有 5 个 BlockAction 视图。做到这一点的最佳方法是什么?

谢谢!

I need to render a view from inside a view.

For the sake of question, i'll call them blocks.

I have 5 controllers, each of them has an action that is called BlockAction(), and it displays some of the information from that controller.

In the Index page for the whole website I need to call all 5 of those BlockAction views. What could be the best way to do this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

霞映澄塘 2024-09-14 02:11:19

您可能想查看 Zend_Layout ,我相信您会发现它是一个更抽象的解决方案,并且可以让您更好地控制视图。基本上,“布局”是其中有多个视图的视图(我知道是多余的)。

You might want to take a look into Zend_Layout, I believe you will find it to be a more abstract solution and give you more control over the views. Basically the "layout" is the view which has multiple views within it (Redundant I know).

£冰雨忧蓝° 2024-09-14 02:11:19

只是添加到已经给出的答案中。

虽然为块提供单独的控制器和操作的方法最符合经典的 MVC 方法,其中 UI 的每个部分都有其相应的控制器,但不建议将其与 Zend Framework 一起使用。

理论上你可以使用 ActionStack Action Helper操作视图助手来调用控制器操作。然而,这将使您的应用程序经历每次调用的完整调度周期。

进一步阅读:

Just adding to the already given answers.

While the approach to have separate controllers and action for blocks is most true to the classic MVC approach, where each part of the UI has it's corresponding controller, it is not advisable to use it with Zend Framework.

In theory you could use the ActionStack Action Helper or Action View helper to call the controller actions. However this would make your application go through the full dispatch cycle for each call.

Further reading:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文