Timely Content Make the text on your page say what you want to say, when you want to say it. To set up your timely content CGI, you first need to write a configuration file. The configuration file does two essential things: 1. It determines which content gets displayed at what times; 2. It contains all the content that can get displayed. To create a configuration file, open up your favorite text editor (something that will save your text as a plaintext file, like Notepad). You can use MS Word, but be sure to choose "Text-only" in the "Save file as..." menu. The configuration file is basically a checklist that the timely content CGI goes through, checking each section to see if the current time and date match the limits set out for that section. Let's look at an example of a configuration file, and then see how the timely content CGI looks through that file: BEGIN: 10/31/99 7:00 pm END: 10/31/99 11:00 pm It's trick-or-treating time! BEGIN: 12/25/99 END: 12/25/99 Merry Christmas! BEGIN: Friday 6:00 pm END: Friday 8:00 pm Yessss - time to go home. DEFAULT Not much to say... Timely content configuration files, like this one, all follow a pattern: They specify a series of BEGIN and END date/times, each followed by some HTML content; they then end with a DEFAULT line, with some content after that. When the configuration file is read by the timely content CGI, it checks the current time and date against each BEGIN/END pair, in order. If the current time and date fall between a BEGIN/END pair, it grabs the content that follows that BEGIN/END, spits it out, and exits. If none of the BEGIN/ENDs match, it goes down to the DEFAULT setting, and grabs the content below it, instead. Going back to our example configuration file, let's say that somebody visits our page with timely content CGI on it, coming in on 12/25/99 at 2:00 am. The CGI grabs this date and time, and starts checking them against BEGIN/END pairs in the configuration file. The first BEGIN/END pair doesn't match - 12/25/99 is after our BEGIN date of 10/31/99, but it's also after the END date, so that doesn't work. With the second BEGIN/END, we have better results. The BEGIN of 12/25/99 matches the current date, and the END does too. Plus, no time was specified for either the BEGIN or END, so anything goes. So, we grab the content - "Merry Christmas!" - and output that in our page. Let's say that another visitor comes along on the next day - 12/26/99, at 4:00 pm. Again, the first BEGIN/END pair doesn't match. This time, neither does the second pair - we're past the END date. What about the third pair? Well, looking at the calendar, 12/26/99 is a Sunday, so that doesn't match. Nothing has matched up, so we are left with the default. We spit out "Not much to say..." Now, let's go over the rules for building your own configuration file. First, make sure that you always put BEGIN and END dates on their own lines. If you don't put them at the beginnings of their own lines, they won't get recognized. Second, remember that CGI will check the BEGIN/END pairs in order, so if you need to check for two different time periods that overlap, make sure that you put the higher-priority time period first. Third, there are a bunch of notes about time and date formatting. Let's go over those now: * You can have either a date or day of the week in a line, but not both. If the CGI sees both, it will ignore the day. * Dates are in the U.S./Canadian format of month/day/year. Use slashes, not dashes. Any of the following would be a formattable date: 9/12/99; 09/12/99; 9/12/1999. * Times are listed as hour:minute; you can't use seconds! 9:34 and 09:34 are both fine. * Times can be either 24-hour or 12-hour; if you use 12-hour, be sure to specify AM or PM. * Days of the week should be spelled out - use "Wednesday", not "Wed." * Make sure your BEGIN/END pairs use the same information - that is, if you use a date and a time in your BEGIN, don't use a day of the week in your END. You may see strange results if you do. * You don't need to have a date/day of the week if you have a time, and vice versa. Once you've named and saved your configuration file, you need to insert it into your page. So, for the sake of argument, we've hypothetically named your configuration file "your_conf_file". The code you need to put into your HTML editor is This is a lot of information and it may seem hopelessly complicated, but really, it's not! Just think of the configuration file as a checklist, where you've provided directions about what to do at different times, and you're almost there. Good luck!
Make your own free website on Tripod.com