如何将标签添加到我现有的非 cms 网站?
有一天,我嫉妒地看着支持 CMS 的 WordPress 网站拥有的所有功能,然后我意识到我错过了一件事情:标记。
有什么方法可以在我的非 cms、非数据库平面文件 php 上拥有这样的东西吗?网站?这基本上是一堆网页文件,例如 home.php
、contact.php
、somepage1.php
、somepage2.php
这实际上可能吗?
在想这样的事情:
- 每个页面都包含
tagsys.php
- 每个页面都有带有一些标签
的页脚banana
、peach
、tomato
- 超链接分别指向
/tags/banana
、/tags/peach
>,/tags/tomato
- 由于没有香蕉/桃子/番茄等实际文件,因此包含的 tagsys.php 必须知道如何排序生成一个新页面,其中捕获带有该标签的每个页面的本质($title 和 $descr),因此所有内容都可以自动化。
I was looking other day jealously at all the features that CMS-enabled WordPress sites have, and I realised one thing that I've missed out: tagging.
Is there any way I can have such a thing on my non-cms, non-database flat files php website? Which is basically bunch of web page files like home.php
, contact.php
, somepage1.php
, somepage2.php
, etc.
is this actually possible at all?
I was thinking of something like this:
- each page includes
tagsys.php
- each page has footer with some tags
banana
,peach
,tomato
- the hyperlinks go respectively to
/tags/banana
,/tags/peach
,/tags/tomato
- since there are no actual files as banana / peach / tomato, the tagsys.php which is included, has to know how to sort of generate a new page, in which it captures the essence ($title and $descr) of every page with that tag, and so all could be automated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以向每个页面添加一个 id(可能是文件名,您可以使用 php 获取: http://www.expertcore.org/viewtopic.php?f=67&p=1453)
然后在数据库存储中创建一个包含标签列表的表和另一个要创建的表页面 ID 和标签之间的关系。
通过这种方式,您将能够轻松创建一种“标签管理界面”。
但正如 Brent Friar 所说,如果可能的话,更愿意升级到现有的 cms,它非常快速且简单,并且会节省您的维护时间!
You could also add an id to each page (it may be the filename, wich you can get using php : http://www.expertcore.org/viewtopic.php?f=67&p=1453)
Then in your DB store create a table with a list of tags and another one to create a relation between your pages IDs and the tags.
In this way you will be able to create a kind of "tag administration interface" easily.
But as Brent Friar said, if possible, prefer upgrading to an existing cms, it's quite fast and easy, and it'll save you hours of maintenance!
只需将您的网站升级到任意数量的支持标记的 CMS,就会变得更容易、更快、更轻松。即使您的网站有数百页,将其移动到 Wordpress 也不难(尽管我会使用更复杂的 CMS,WP 是一个易于使用的优质产品)。
请记住,在静态站点上,每次创建新页面时都必须更新标签关联。这将是一场行政噩梦。
It would be a lot easier, faster, and less headache to simply upgrade your website to any number of CMSs that support tagging. Even if your site has several hundred pages it would not be hard to move it to Wordpress (though I would use a more sophisticated CMS, WP is a fine product that is easy to use).
Keep in mind that on a static site you are going to have to update the tag associations every time you create a new page. It would be an administrative nightmare.