Forum Moderators: phranque
I'm using the following conditional ssi call to include a certain file depending on the day of the month (only showing day 1 and day 7 ... which is today's date:
<!--#config timefmt="%d" -->
<!--#if expr="$DATE_LOCAL = 01" -->
<!--#include file="tip1.html" -->
<!--#elif expr="$DATE_LOCAL = 07" -->
<!--#include file="tip7.html" -->
<!--#endif -->
So, today it should be including the file called tip7.html into a page called tod.shtml, but it's not working. No error messages or anything, just not including the file. All files are in the same directory.
Any suggestions appreciated!
Thanks!
<!--#config timefmt="%d" -->
<!--#if expr="${DATE_LOCAL} = /01/" -->
<!--#include virtual="tip1.html" -->
<!--#elif expr="${DATE_LOCAL} = /07/" -->
<!--#include virtual="tip7.html" -->
<!--#else -->
<!--#set var="errmsg" value=" No date handler file available " -->
<!--#echo var="errmsg" -->
<!--#endif -->
Thanks for trying to help. However, I'm getting some strange results. Sometimes it displays the right file and sometimes it displays the content of files for other dates, even though today's date is the 8th. It seems like your code should be displaying the error message since today's date is not one of the options.
Aside from that, I've changed my statements to look like yours, but if I keep hitting refresh repeatedly, sometimes I get different files included. It's strange.
Any ideas?
Here's my complete code:
<!--#config timefmt="%d" -->
<!--#if expr="${DATE_LOCAL} = /01/" -->
<!--#include virtual="tip1.html" -->
<!--#elif expr="${DATE_LOCAL} = /02/" -->
<!--#include virtual="tip2.html" -->
<!--#elif expr="${DATE_LOCAL} = /03/" -->
<!--#include virtual="tip3.html" -->
<!--#elif expr="${DATE_LOCAL} = /04/" -->
<!--#include virtual="tip4.html" -->
<!--#elif expr="${DATE_LOCAL} = /05/" -->
<!--#include virtual="tip5.html" -->
<!--#elif expr="${DATE_LOCAL} = /06/" -->
<!--#include virtual="tip6.html" -->
<!--#elif expr="${DATE_LOCAL} = /07/" -->
<!--#include virtual="tip7.html" -->
<!--#elif expr="${DATE_LOCAL} = /08/" -->
<!--#include virtual="tip8.html" -->
<!--#elif expr="${DATE_LOCAL} = /09/" -->
<!--#include virtual="tip9.html" -->
<!--#elif expr="${DATE_LOCAL} = /10/" -->
<!--#include virtual="tip10.html" -->
<!--#elif expr="${DATE_LOCAL} = /11/" -->
<!--#include virtual="tip11.html" -->
<!--#elif expr="${DATE_LOCAL} = /12/" -->
<!--#include virtual="tip12.html" -->
<!--#elif expr="${DATE_LOCAL} = /13/" -->
<!--#include virtual="tip13.html" -->
<!--#elif expr="${DATE_LOCAL} = /14/" -->
<!--#include virtual="tip14.html" -->
<!--#elif expr="${DATE_LOCAL} = /15/" -->
<!--#include virtual="tip15.html" -->
<!--#elif expr="${DATE_LOCAL} = /16/" -->
<!--#include virtual="tip16.html" -->
<!--#elif expr="${DATE_LOCAL} = /17/" -->
<!--#include virtual="tip17.html" -->
<!--#elif expr="${DATE_LOCAL} = /18/" -->
<!--#include virtual="tip18.html" -->
<!--#elif expr="${DATE_LOCAL} = /19/" -->
<!--#include virtual="tip19.html" -->
<!--#elif expr="${DATE_LOCAL} = /20/" -->
<!--#include virtual="tip20.html" -->
<!--#elif expr="${DATE_LOCAL} = /21/" -->
<!--#include virtual="tip21.html" -->
<!--#elif expr="${DATE_LOCAL} = /22/" -->
<!--#include virtual="tip22.html" -->
<!--#elif expr="${DATE_LOCAL} = /23/" -->
<!--#include virtual="tip23.html" -->
<!--#elif expr="${DATE_LOCAL} = /24/" -->
<!--#include virtual="tip24.html" -->
<!--#elif expr="${DATE_LOCAL} = /25/" -->
<!--#include virtual="tip25.html" -->
<!--#elif expr="${DATE_LOCAL} = /26/" -->
<!--#include virtual="tip26.html" -->
<!--#elif expr="${DATE_LOCAL} = /27/" -->
<!--#include virtual="tip27.html" -->
<!--#elif expr="${DATE_LOCAL} = /28/" -->
<!--#include virtual="tip28.html" -->
<!--#elif expr="${DATE_LOCAL} = /29/" -->
<!--#include virtual="tip29.html" -->
<!--#elif expr="${DATE_LOCAL} = /30/" -->
<!--#include virtual="tip30.html" -->
<!--#elif expr="${DATE_LOCAL} = /31/" -->
<!--#include virtual="tip31.html" --><!--#else -->
<!--#set var="errmsg" value=" No date handler file available " -->
<!--#echo var="errmsg" -->
<!--#endif -->
Thanks for taking a look.
kelly
<!--#config timefmt="%S" -->
<p>DATE_LOCAL "%S" = <!--#echo var="DATE_LOCAL" -->
<!--#if expr="$DATE_LOCAL = /0[0-9]/" -->
<br>Second = 0-9
<!--#elif expr="$DATE_LOCAL = /1[0-9]/" -->
<br>Second = 10-19
<!--#elif expr="$DATE_LOCAL = /2[0-9]/" -->
<br>Second = 20-29
<!--#elif expr="$DATE_LOCAL = /3[0-9]/" -->
<br>Second = 30-39
<!--#elif expr="$DATE_LOCAL = /4[0-9]/" -->
<br>Second = 40-49
<!--#else -->
<br>Second = 50-59
<!--#endif -->
</p>
Note also that the DATE_LOCAL variable references are different between the "#echo var=" and "expr=" directives.
Jim
Assuming I'm understanding your last post, it looks like mine is returning the seconds incorrectly. It looks like it's reading the "hours" rather than the seconds because this is what your code returned on my page:
DATE_LOCAL "%S" = Saturday, 10-Feb-2007 09:20:33 EST
Second = 0-9
Is that what you make out of it?
Thanks!
Edit: I added the no-cache tag to my page as well, but same results.
The output you should have seen from the first 'echo' directive is:
DATE_LOCAL "%S" = 33
So, it's apparent that your server did not accept the time format configuration, and used the default configuration instead, resulting in the entire date and time being printed.
The subsequent code then matched on the the first "if" statement because it found two matching digits -- the "00" in "2007". So it printed "Second = 0-9."
This might be an SSI misconfiguration or a permissions restriction, and all I can suggest is to contact your host or server admin and ask them why "config timefmt" won't work.
Jim