如何在 php 中创建存档列表? [英] How to create an archive list in php?

查看:17
本文介绍了如何在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆