tadej.eu

A blog about game development, web technology
and entrepreneurship by Tadej Gregorcic

Drupal Published Date equals Effective Date fix

by Tadej Gregorcic on December 29, 2008

We have a gaming site where the node creation date is irrelevant to the user as they only see it once it is published by our moderators.

Surprisingly, there is no “published on” date in the original Drupal database, so the Views can only sort by the mysterious “created on” date.

As I didn’t want to hammer this problemmette away with the formidable Scheduler module, here’s a quick fix.

Get the Rules module and add this triggered rule:

  • After updating existing content
  • Conditions: updated content type fits, NEGATE “unchanged content is published”, “changed content is published”
  • Custom PHP action:

$node->created = time();
return array(“node” => $node);

Seems to work just fine.

Now I can use the “posted on” date in Views to display the games in a logical manner. Too bad there is no way to do this retroactively.

Here’s my Rules screen shot:

Drupal Published-on Date Rule

And a related article: http://drupal.org/nyobserver.

Reblog this post [with Zemanta]
blog comments powered by Disqus

Previous post:

Next post: