PDA

View Full Version : Content Schedule?


jsarber
Thu., Aug. 23, 2007, 3:08 pm
Any suggestions as to how I might cause certain content to regularly change at a specified time each day? It would have to change code and not just text or images. I have a daily Bible illustration on my site with text, an image, and a Bible verse that I manually change each morning. Anyway I can automate this?

David Gillaspey
Thu., Aug. 23, 2007, 11:59 pm
Hi Jeremy,

1. It's possible that something known as a chron job would be the solution. This is a small program that does regularly scheduled tasks on Unix systems. See

http://en.wikipedia.org/wiki/Cron
http://www.linuxhelp.net/guides/cron/

This handles the scheduling. It doesn't speak to the issue of exactly how the content would be changed, but it at least handles the scheduling part.

2. A second option is to tie into some other service that already has this figured out, at the risk of your giving up control over which verse appears each day. Do you, in fact, care which verse appears each day?

Here is one source: http://www.biblegateway.com/usage/.

3. As I recall you are using a content management system or forum software. Consider searching for a mod, extension, or plugin for your software that accomplishes your purpose.

4. If you are using PHP, set this up as include files. On my website, which hosts this forum, I have been engaged for some time in updating The International Directory of Church Website Design (http://www.greatchurchwebsites.org/results.php?sR=Yes&Display%21=Display+churches%21&sT=&bS=1&sC=10&sO=ASC), of which I am the editor. I report my progress at this in the lefthand column of my site:

http://www.greatchurchwebsites.org/art/FORUM/directory_update_example.jpg.

I've circled two items. Both are drawn from PHP include files that contain nothing but a little bit of text. I don't have to touch the HTML page — just update the include files and upload those to the server.

generalhavok
Fri., Aug. 24, 2007, 7:50 am
You can use a single PHP script that checks the time of page load and then inserts the right bit of code at the right time. The logic would go like this:

IF time > 12:01am & < 12:00pm, display MorningImage.jpg
ELSE
IF time > 12:01pm & < 6:00pm, display AfternoonImage.jpg
ELSE
IF time < 6:01pm & < 12:00am, display EveningImage.jpg
DEFAULT
display AlldayImage.jpg

That's not anything like the actual code that would make it work, and it's not even close to complete...I just wrote it to let you know that there's a logical path you can take to create time-based behaviors on a web page. There are lots of tutorials for just about everything online, so some searching should help you find the scripts that others have written...and, with a little work, you can adjust them to meet your needs.

jsarber
Fri., Aug. 24, 2007, 2:32 pm
Thank you. I am, by no means, experienced with PHP and SQL. I used phpBB forums and have made many modifications to it as well as building my site around them. I imagine I can figure out what you're talking about. I assume there was a way using PHP and your comments have given me a better start at researching this. Thanks again.

tmreg
Sat., Aug. 25, 2007, 2:53 pm
On the front page of one of my sites, Church Doctor Ministries, has a content rotator like I think you are talking about. Every day has a different "Apple a day" message. This is automatically updated each night at midnight using a simple php code. I have 366 separate html files (named 1.html, 2.html, ...366.html) , each one with a different message. I basically call for the html file to display and the name of the file being called is the date (using the php date variable for the julian date, or numbered day of the year.) So January 1 uses "1.html" and December 31 uses 365.html.

You can use this technique with whatever you are creative enough to use it for. Maybe use the php variable for hour of the day or something like that. My php file looks like this:
<?php

print date(" l, F j, Y ");
$date = date("z");
$date = $date +1;
$date="http://churchdr.org/apple_a_day/".$date . ".html";

$buffer = file_get_contents($date);
print $buffer;

?>

By the way, I only have the "$date+1" in the code because the php variable starts at 0 and not 1 so my timed messages (christmas, easter, etc) were off by a day. A quick fix to keep me from having to rename 366 files.