如何在php中创建存档列表? [英] How to create an archive list in php?
问题描述
我正在创建我的公司博客,并想知道如何创建一个存档页面,读者可以在其中单击月份/年份并显示该时间段内的所有博客文章.
I am creating my companies blog and would like to know how to go about creating an archive page where the reader can click on the month/year and display all blog posts for that time period.
这些天,我经常在博客上看到此消息,并想知道如何自己创建它.
I see this very often on blogs these days and would like to know how I can myself create it.
它看起来像这样:
- 2012年7月
- 2012年6月
- 2012年3月
很明显,我希望通过引用博客表中的时间字段来动态创建列表,但是从哪里开始?
Obviously I would want the list created dynamically by referencing the time field in my blog table, but where to start?
是否有有关如何实现此目的的文档?
Is there any documentation on how to implement this?
我正在从头开始创建自己的博客.
I am creating my own blog from scratch.
推荐答案
如果您使用的是数据库,则可以简单地使用时间戳根据日期对文章进行分组.
If you are using a database, you can simply use timestamps to group articles based on date.
如果您不使用数据库,则可以使用文件系统,并将每篇文章放在相关的结构中:
If you aren't using a database, you can use the filesystem, and place each article in a relevant structure:
/articles/2011/July/article_name_here.html
/articles/2011/July/article_name_here.html
这篇关于如何在php中创建存档列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!