Drupal solutions for news sites: Creation date vs. publish date

This is part 3 in a series of posts about Drupal solutions for common issues raised in developing news sites. See a brief preamble in my first entry about the topic.

Solution 3: "This article says it was published way earlier than it was actually published."

This is a seemingly small problem, and a quick fix. But it's subtle, and a good illustration and how sometimes the programmers and journalists have different ways of thinking about the content.

The first time someone brought this to my attention, I was confused. It sounded like a bug report. Perhaps I was using some kind of bad date stamp format in the date() function or something. The conversation went something like this:

Me- "So the article says it was created several hours earlier than you created it?"
Producer- "Yeah. I just published it now, actually, but it says it was published yesterday afternoon."
Me- "Wait, published or created?"
Producer- "Published, I guess? What's the difference?"

As you might be able to guess, what I was referring to was the time at which the node had been first inserted into the database. In my mind, as a programmer, this is the true "creation" date of the article. To the editorial people, this is not meaningful. They routinely create articles in what we internally call "draft mode" (i.e., with "published" unchecked in the node form). By their logic, the date displayed on an article should be the moment at which it first become available for public consumption -- that is, the time at which the node was edited in such a way that "published" went from false to true. When the article was first inserted (as a draft) doesn't matter at all to them.

To do this requires a trivial (but clever, in my opinion) fix. You will need to create a new module, so see this tutorial if you're not familiar with the process. Your module can consist entirely of the following code (let's name the module "article_form"):

/**
 * Implementation of hook_form_alter.
 */
function article_form_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    if ($form['#node']->nid && !$form['#node']->status) {
      unset($form['author']['date']['#default_value']);
    }
  }
}

This code will simply blank out the creation date field on a node when it's being edited and is currently marked as unpublished. If this field is blank on node submission, it will be automatically set to the present time. This means that each edit of the node when it's unpublished will bump the date up to the current time, until the edit that publishes it, which is the one that counts. Once it's published, that existing date will remain the default for further edits. As usual, change "article_node_form" to "story_node_form" or "danceparty_node_form" or whatever the name of your node type is.

The only caveat here is that if the article is unpublished at any point, the date will blank out again. Probably not that big of a deal since that's not something you'd be likely to do unless the article needed some serious reworking, so you could manually reset the date if it were that big of a deal.

Comments

nike air max

E-team008 ruanruan

Your insights are unique! I am so admire you!
air max Love plays a pivotal role on out life.
lady gaga headphonesLove makes you feel wanted.
heartbeats by lady gagaWithout love a person could go hayward and also become cruel and ferocious.beats by dr dre headphonesIn the early stage of our life,
air max ltdour parents are the ones who shower us with unconditional love and care,dr. dre headphonesthey teach us about what is right and wrong,nike air max 2 good and bad. nike air maxBut we always tend to take this for granted.adidas originals shoes It is only after marriage and having kids that a person understands and becomes sensitive to others feelings.
adidas superstar shoes Kids make a person responsible and mature and help us to understand life better.adidas classic shoes

dropshippingwatch

Baume & Mercier Riviera XXL Working Chronograph wtih Black Dial
Baume & Mercier Riviera Chronograph with Black Dial and White Bezel
Baume & Mercier Riviera 200 Meters Quartz Movement Black Bezel with Black Dial and Ssband Strap
http://www.dropshippingwatch.com/baume-mercier-riviera-200-meters-quartz-movement-black-bezel-with-white-dial-and-ssband-strap-p-14074.html
Baume & Mercier Riviera 100 Meters Quartz Movement Sliver Bezel with Black Dial and Green Marking
Baume & Mercier Riveria XXL Chrono SS/RU White Dial and Bezel,Yellow Marking and Rubber Strap
Baume & Mercier Geneve Riviera XXL Working Chronograph Full Silver with White Bezel and White Dial-Roman Marking and Small Calendar
Baume & Mercier Classic Working Chronograph with White Dial-Sapphire Glass
Baume & Mercier Classic Working Chronograph with Black Dial-Sapphire Glass
Baume & Mercier Classic Working Chronograph with Number Marking-Sapphire Glass
Baume & Mercier Classic Working Chronograph with Black Dial-Sapphire Glass
Baume & Mercier Classic Working Chronograph with White Dial-Sapphire Glass
Baume & Mercier Riviera XXL Working Chronograph White Dial with Black Bezel Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with Black Dial and Bezel Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with Black Dial and Bezel Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with Black Dial Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with Black Dial Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with White Dial Same Chassis As 7750-High Quality
Baume & Mercier Riveria Magnum Chronograph Asia Valjoux 7750 Movement PVD Case with Black Dial-28800bph
Baume & Mercier Classic Working Chronograph with White Dial
Baume & Mercier Hampton Milleis with Black Dial
Baume & Mercier Classic Working Chronograph Two Tone with White Dial
Baume & Mercier Classic Chronograph Automatic Two Tone with White Dial
Baume & Mercier Classic Working Chronograph Two Tone with Black Dial
Baume & Mercier Hampton Milleis with White Dial
Baume & Mercier Classic Working Chronograph Two Tone with Golden Dial
Baume & Mercier Riviera XXL Working Chronograph with Black Dial and Bezel
Baume & Mercier Riviera XXL Working Chronograph with Black Dial Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph White Dial with Black Bezel Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with Black Dial Same Chassis As 7750-High Quality
Baume & Mercier Riviera XXL Working Chronograph with White Dial Same Chassis As 7750-High Quality

Thanks for this helpful

Thanks for this helpful resource, i try this cote and it works for me ! congrats !
bonus betclic

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 18 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.