如何添加“热门事件/最近更新”部分到使用 Symfony 1.4 构建的网站?
我正在使用 symfony 1.4 开发一个网站。用户上传照片并将照片保存在数据库中。
现在在主页上,我有一些内容,我想要有一个部分显示最近上传的照片。我不确定这样做的最佳方法是什么。你能指出我正确的方向吗?
我能想到的唯一方法是让 $sf_content
保存主要内容(将来自应用程序/模块),并且对于最近的上传,让 layout.php
执行数据库访问+业务逻辑+渲染,但这会违反MVC,并且每次用户在网站中导航时都会涉及大量的数据库访问。
可以做得更好吗?
I'm developing a website with symfony 1.4. The users upload photos and the photos are saved in a database.
Now on the homepage, I have some content and I want to have a section that shows the recently uploaded photos. I'm not sure what is the best way of doing this. Could you please point me in right direction?
The only way I can think of is to have $sf_content
hold the main content (which will come from the app/modules) and for recent uploads, have layout.php
do database access+business logic+rendering but that will violate the MVC and will involve huge database access every time the user navigates in the website.
Can it be made better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用组件。
apps/yourapp/modules/yourmodule/actions/components.class.php
在模型中:
在您的 apps/yourapp/modules/yourmodule/themplates/_rfoto.php 中
在 layout.php 或其他您想要放置照片的地方:
You can use components.
apps/yourapp/modules/yourmodule/actions/components.class.php
In model:
in your apps/yourapp/modules/yourmodule/themplates/_rfoto.php
And In layout.php , or other place where you want to put your photo: