页眉和页脚的自定义

发布于 2024-10-03 08:56:35 字数 99 浏览 1 评论 0原文

我有一个网页,我必须允许用户自定义他们的页眉和页脚。 即我应该存储用户页眉和页脚 HTML 并动态地将其添加到网页中。我有两种存储在数据库中和存储在文件中的方法。请建议我哪种方法更好。

I have a webpage where i have to allow the users to customize their header and footer.
i.e. I should store the Users header and footer HTML and should dynamically add it to the webpage. I have two ways of storing in database and storing in a files. Please suggest me which approach is better.

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

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

发布评论

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

评论(3

难以启齿的温柔 2024-10-10 08:56:35

随着时间的推移,文件的解决方案变得更加混乱。有了数据库,就更容易扩展。

使用数据库,您可以添加簿记字段(例如上次修改时间、标签或其他内容,具体取决于您的需要)。备份也许也更容易。

对于文件,您必须担心目录结构(单个目录中文件太多不好)、权限等。

如果您担心效率,请停止担心:)。 MySQL 查询非常快,特别是使用 apache 中的缓存机制/模块。

Solution with files get messier with time. With databases, it is easier to scale.

With databases, you can add bookkeeping fields (like last-modified, tags, or something else depending on your need). Backup is easier also perhaps.

With files, you have to worry about directory structure (having too many files in single directory is not good), permissions, etc.

If you are worried about efficiency, stop worrying :). MySQLqueries are pretty fast especially with the caching mechanisms/modules in apache.

茶色山野 2024-10-10 08:56:35

这不是更好的方法(一般都有优点和缺点),但在这种特定情况下,我会将这些片段存储为文件,因为肯定会降低复杂性(因为你不需要查询数据库并获取结果)并且您不依赖数据库连接来包含页眉和页脚

Ther's not a better approach (there are pro and cons in general) but in this specific case I would store these snippet as a file because you have less complexity for sure (because you don't need to query a database and fetching result) and you don't relies on database connection for including header and footer

心奴独伤 2024-10-10 08:56:35

如果您使用 .Net,您可以使用称为 Portals 的东西来完成同样的事情。您可能还想阅读诸如母版页之类的内容。但所有这些都在.Net 中。即使您不在 .Net 中执行此操作,自行处理所有这些内容也会非常耗时,因为您需要处理跨站点脚本编写和其他一些问题。

检查您正在开发的功能平台,看看它们是否可以实现这一点。 (让我知道您正在使用的平台,以便我可以提供帮助)。另外,如果更改只是装饰性的,您可以只存储 css 设置而不是完整的 html。

最后,如果要存储的更改数量超过 100,最好使用 sql,因为复杂性会让您感到困扰。但如果您的用户较少并且不期望任何扩展,那么一定要选择文件系统。

:
以下是一些用于了解 .Net 中的门户和 Web 部件的链接:

If you're using .Net you've something called Portals which does the same thing. There are things like master pages also that you may want to read. But all these are in .Net. Even if you're not doing this in .Net it'd be time consuming to handle all this stuff on your own as you need to take care of cross-site scripting and a few other issues.

Check the platform for features that you're working on to find out if this is possible by them. (Let me know the platform that you're using so I may help in that). Also, if the changes are just cosmetic you may store just css settings instead of complete html.

Finally it'd be better to use sql if the number of changes to store are more than 100 as the complexity will bug you down. But if you're fewer users and don't expect any scaling up then sure go for a file system.

:
Here are a couple of links for understanding portals and web parts in .Net:

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