我需要帮助了解 Zend Framework (MVC) 页眉和页脚最佳实践

发布于 2024-09-25 15:19:41 字数 540 浏览 6 评论 0原文

我是 MVC 和 Zend Framework 的新手,我正在开发一个项目,主要是前端项目。我试图了解什么是最佳实践。

目前,页脚和页眉是通过几个脚本设置的,其中一个是网站上所有内容的巨大 XML 文件(我认为为了使网站国际化,内容都包含在 i18n 标签中),一个存储所有链接进入一个数组,一个循环遍历所有页脚/页眉链接的数组,以及一些其他文件,我不完全确定它们的作用,但它们最终都会吐出一个简单的页脚或页眉链接的 ul。

这一切对我来说似乎很复杂,为什么页眉和页脚不只是布局中的简单 html 链接,或者是主 layout.phtml 的一部分,或者作为包含的 footer.phtml?

简单的提交按钮也用作长视图/帮助程序脚本,当我认为没有理由它们不能只是简单的 HTML 时。

我知道业务逻辑留给模型,视图应该是用于布局的更轻的前端脚本。但特别是对于 Zend 框架和 Web 开发,任何有关什么到底属于简单 HTML 以及什么应该更复杂作为辅助 php 脚本/模型脚本的指导将不胜感激。

至少能够理解页脚和页眉的最佳实践将帮助我开始。

抱歉有点长,再次感谢。

I'm new to MVC and Zend Framework and I'm working on a project, mostly on the front end. I'm trying to get a sense of what are best practices.

Currently the footer and header are setup through several scripts, one that is a giant XML file of all the content on the website (I think to make the website international friendly, things are wrapped in i18n tags), one that stores all of the links into an array, one that loops through all of the footer/header links, and some other files that I'm not totally sure what they do but they all eventually spit out a simple ul of footer or header links.

It all seems so convoluted to me, why isn't the header and footer just simple html links in layouts, either a part of the main layout.phtml or as an included footer.phtml?

Simple submit buttons are also used as a long views/ helper script, when I see no reason they couldn't just be simple HTML.

I know business logic is left for models, and views are supposed to be lighter front-end scripts for layout. But specifically for Zend framework and web development, any guidance on what exactly belongs as simple HTML and what should be more complex as a helper php script/model script would be much appreciated.

At least just being able to understand what's best practices for a footer and header would help me get started.

Sorry about the length, thanks again.

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

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

发布评论

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

评论(1

月寒剑心 2024-10-02 15:19:41

假设整个事情是一个布局视图脚本,以下是我的看法:

  • 没有正确的答案,这实际上取决于项目的范围。
  • 我通常使用单个视图脚本,但根据复杂性将一些复杂区域转移到部分视图脚本甚至视图助手。
  • 迭代数据是有意义的;如果内容来自外部源,您不希望对其进行硬编码。简单的输出并不重要......考虑输入(内容)。
  • 表单元素通常与业务逻辑密切相关......它允许后端开发人员控制与设计无关的某些方面。

IMO,这个问题可能更适合那些对当前内容进行编码的人...ZF 非常开放,它不会强迫您使用任何特定的组织方法。我会快速阅读一下视图助手文档,因为它可能有助于阐明所使用的某些视图助手以及您可能想要使用的其他视图助手。

http://framework.zend.com/manual/en/zend.view .helpers.html

Assuming the whole thing is a layout view script, here are my opnions:

  • There is no correct answer, it really depends on the scope of the project.
  • I typically use a single view script, but depending on complexity shift some of the complex areas to partial view scripts or even view helpers.
  • Iterating over data makes sense; if content comes from an external source, you do not want to hardcode it. Simple output doesn't matter... consider the input (content).
  • Form elements are typically closely related to business logic... It lets the back-end developer control certain aspects of them that aren't design-related.

IMO, this question may be better suited towards the guys that coded what's currently there... ZF is very open ended, and it does not force you to use any specific organization methods. I'd give the view helpers documentation a quick read-over as it may help shed some light upon certain view helpers that are used, as well as others you may want to use.

http://framework.zend.com/manual/en/zend.view.helpers.html

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