Home     SSI Lab     CSS Templates     CSS     Htaccess     Web Design     XHTML

X-SSI Lab

graphic-img   

SSI-D HOME

SSI LAB

Introductory Topics

SSI Directives

Extending SSI

Apps/Examples

Top Resources

CSS Templates

CSS

.Htaccess

Web Design

(X)HTML

HTML-Kit

Resources





Basics of Conditional SSI

Introduction

This guide introduces the very basics of conditional SSI with some simple examples.


Conditional SSI "Flow Control" allows you to test for certain variables and display content depending on what those variables are. To better explain it consider the following scenario:

If your browser is Netscape:
   "Netscape Rules!"
or else if your browser is Internet Explorer:
   "IE Rocks!"
otherwise:
   "display no message"
End

The correct syntax takes this basic format:

<!--#if expr="expression" -->
   "something here"
<!--#elif expr="expression" -->
   "something else here"
<!--#else -->
   "something different here"
<!--#endif -->

To show this in a working example we are going to display a simple message depending on what day of the week it is.

First we configure the time format for the full weekday name, then we check what day of the week it is and attach the appropriate message:

<!--#config timefmt="%A" -->
<!--#if expr="$DATE_LOCAL = /Monday/" -->
<p>I hate mondays!</p>
<!--#elif expr="$DATE_LOCAL = /Friday/" -->
<p>Yeeah, it's Friday!</p>
<!--#else -->
<p>No comment!</p>
<!--#endif -->

Conditional SSI is where it gets exciting as it allows you to add a great deal of dynamism and personalisation to your pages and so is important to learn and experiment with. More examples & applications are accessible through the main SSI page.

It's also important to check out the conditional expressions page to learn what 'operators' can be used with conditional SSI.




Advertisement Sign up for free to PayBox.me today and get $25 just for joining AND earn up to $20 per day for participating.