formmailer Posted November 26, 2011 Share Posted November 26, 2011 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 More sharing options...
apeisa Posted November 26, 2011 Share Posted November 26, 2011 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 More sharing options...
ryan Posted November 27, 2011 Share Posted November 27, 2011 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 More sharing options...
formmailer Posted November 28, 2011 Author Share Posted November 28, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now