使用Zend Framework呈现站点范围内元素的最佳方法 [英] best approach to render site-wide elements using Zend Framework
问题描述
我正在使用模块"前端控制器资源进行项目设置. 呈现整个网站元素(如导航)的最佳方法是什么?
I'm using the 'modules' front controller resource for the project setup. What's the best approach to render site-wide elements, like navigation?
- 在每个请求的操作堆栈末尾添加使元素呈现的操作?
- 可以通过控制器动作呈现这些元素吗?
- Add the action which renders the element to the end of the action stack each request?
- is it OK to render these elements through controller actions?
- 我可以使用模块专用的插件吗?
推荐答案
我认为应该避免操作堆栈. 请参阅这篇文章,了解原因.
I think the action stack should be avoided. See this article for why.
该插件方法可以工作,或者您可以创建从布局脚本调用的ViewHelpers.我喜欢ViewHelpers方法,因为它可以使所有内容保持清晰.您知道,当您回显$ this-> mainNaviation()时,会有一个名为MainNavigation的ViewHelper.
The plugin method could work or you can create ViewHelpers which you call from you layout script. I like the ViewHelpers method because it keeps everything very clear. You know that when you echo out $this->mainNaviation() that there is a ViewHelper called MainNavigation.
这篇关于使用Zend Framework呈现站点范围内元素的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!