Update block content at specified time each night
Permalink
I have a client that has a peculiar request to have the content of a block be updated at around mid-night each night to some default content. Each morning that same content block could then be changed to any content of their choosing until it is reset again the following night at around mid-night. For some reason I've been having a hard time getting my mind around the best way to do this. This ideally would be coded into the page type because there are multiple pages that would be using this code and each block would have the same default content that could be updated by an admin the next morning to any content of their choosing. Any suggestions on the best way to approach this?
Thanks for the reply John. I wouldn't be updating a page but just a block on multiple pages. My thought on this would be to grab the blockid, the block last modified date, current date and the content in the block and then check to see if the modified date and the current date matched. If the current date was greater than the modified date (i.e. next day) then I would then check to see if the content in the block is the default content or not. If it wasn't the default content I would update the content using the blockid and update the modified date. This would be done on page load. I've started going down this road. If anyone has a better solution please let me know.
I don't know if it is the best way, but you can create a cron job to run a script daily that resets the page.
If your host uses cPanel, this basic article on creating a cron job may help:
http://www.webhostinghub.com/support/edu/cpanel/303-cron-job...
I hope this helps,
John-Paul