简体   繁体   English

如何存储自定义页眉

[英]How to store custom page headers

Another 'design' question. 另一个“设计”问题。

(Technologies in use: PHP , MySQL ) (使用的技术: PHPMySQL

I need to allow customers to customize the looks of their pages' headers. 我需要允许客户customize the looks页面标题customize the looks What is the best way to store such customized headers (say pieces of html closed in a div). store此类自定义标头的最佳方式是什么(比如在div中关闭的html片段)。 Is storing them in database any good? 将它们存储在数据库中有什么好处?

Or would it be better to store them in php files and include them to each page instead of default header? 或者将它们存储在php文件中并将它们包含在每个页面而不是默认标题中会更好吗?

Or perhaps allowing users to edit html is a very bad idea and I should use some other means for allowing them to customize their headers? 或者也许允许用户编辑html是一个非常糟糕的主意,我应该使用其他方法来允许他们自定义标题? (mostly they use it to put a logo + some additional information, sometimes animated gif with advert, sometimes just text... no rule). (主要是他们使用它来标识+一些额外的信息,有时用广告制作动画gif,有时只是文字......没有规则)。

Please advise. 请指教。

Storing them on the local filesystem is the most performant and simpler one, so you may want to go with this one. 将它们存储在本地文件系统上是最高性能和更简单的一个,所以你可能想要使用这个。

However this will not be as good once you have to scale on multiple servers. 但是,一旦必须在多个服务器上扩展,这将不会那么好。 The better solution then is to use some kind of shared storage (the mysql database solution), and to eventually cache the templates somewhere. 那么更好的解决方案是使用某种共享存储(mysql数据库解决方案),并最终在某处缓存模板。

Html in a database is bad practice it might brings encoding issues (not too hard to resolve but still, a pain in the a##). 数据库中的Html是不好的做法,它可能带来编码问题(不太难解决,但仍然是##的痛苦)。

what you should do is define the level of customization you want to achieve and create the php classes that will allow you to create such a customized header from your code. 您应该做的是定义您想要实现的自定义级别,并创建允许您从代码中创建这样的自定义标头的php类。 You will then have to store in your DB the values needed to rebuild this header on the fly. 然后,您必须在数据库中存储动态重建此标头所需的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM