Search code examples
phplistblogsarchive

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.

It will look something like this:

  • July 2012
  • June 2012
  • March 2012

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.


Solution

  • 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