Results 1 to 2 of 2

Thread: break lines after dates on blog posts

  1. #1
    Join Date
    Jul 2010
    Posts
    5

    break lines after dates on blog posts

    Hi,

    I'm currently attempting to build my first blog using PHP. I'm doing pretty well so far, and I've got a fully functional blog with archives and comments set up.

    My question, I am trying to set it up so that I can create line breaks after the date changes between blog posts. For example, if I post two entries on July 19th, then one entry on July 20th, the two blog posts on July 19th will be grouped together in the same "Date Posted" while the July 20th post will start a new "Date Posted" section. An example of this kind of blog is found on the woot.com blog, http://shirt.woot.com/Blog/ .

    Help me, PHP gurus!

    Thanks.

  2. #2
    Join Date
    Dec 2009
    Location
    San Diego, California
    Posts
    161
    This sounds like a logic question, not so much a PHP-specific question.

    Here's the logic you need to examine:

    A. Loop through the articles you want to display
    B. Compare the date of the present article with the date of the previous article
    C. If the date is different or no previous date has been stored, insert a line break (you could split this up into two if statements if you dont want a line break on "no date has been stored")
    D. Display the article
    E. Remember the date of this article in a variable for comparison on the next article

    Pseudo Code:

    if(!$rememberedArticleDate || $rememberedArticleDate!=$currentArticleDate) {
    // ... insert the break (html stuffs)
    }
    // display article (html stuffs)

    $rememberedArticleDate = $currentArticleDate;

Similar Threads

  1. Replies: 0
    Last Post: 06 Apr 2010, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •