Jump to content

Scheduled posts


formmailer
 Share

Recommended Posts

Hi,

I need to schedule some posts/articles (both start and end date). What would be the best approach for this?

I was thinking about a (lazy)cron job calling a page that changes the status of the page based on the current date.

Would this be a good solution or is there a better way?

/Jasper

Link to comment
Share on other sites

I have similar need, but I am going with simpler template based approach:

I check for dates and redirect to "Page not available" page if article is not published (and you don't have edit access). Only drawback here is that you have to remember to check those dates also when doing lists and searches. Normally that is not a problem, since I use same functions every time.

Link to comment
Share on other sites

I think that using LazyCron or regular cron (with a PW bootstrapped shell script) is a good way to go for auto-scheduling stuff like this. I'd recommend using an unpublished status for pages that shouldn't appear on the site yet, and then changing them to published once the time is right. Something like this:

<?php
$unpublished = $pages->find("status=unpublished, publish_date<" . time()); // assuming publish_date is your date field's name
foreach($unpublished as $p) {
    $p->removeStatus(Page::statusUnpublished); 
    $p->save(); 
}
Link to comment
Share on other sites

Thanks guys! I think I'll try out Ryan's suggestion and will do the same for the page expiry date.

I'll try to make it as general as possible, so others can use this as well. Would it be useful to create a module for this?

/Jasper

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...