views:

27

answers:

1

I want to introduce some random* behavior into an otherwise static html file. I want to experiment with two different advertising schemes, and I want to have the page erved randomly with either one or the other. It seems like overkill to use a scripting language to generate the whole thing, so I thought SSI would be ideal.

I want to do something like this:

<!--#if expr="shouldIdoA" -->
... do A ...
<!--#else -->
... do B ...
<!--#endif -->

The part I am not sure about is how to decide between A or B.

* I really just want it to go one way about 50% of the time, and the other way about 50% of the time, so true randomness is not important. Even something as simple as deciding if the seconds part of the current time is even or odd would work for me.

+1  A: 

As I was writing the last part of my question, I got to thinking about how I could use the time to do what I needed. I came up with a workign solution which is by no means random, but it does serve up one ad or the other, in an even fashion.

<!--#config timefmt='%S' -->
<!--#if expr='$DATE_LOCAL > 30' -->
... do A ...
<!--#else -->
... do B ...
<!--#endif -->

So, this will serve up one version if we are in the first half of the minute, and the other version if we are in the second half of the minute.

Please chime in if you know of any different/better way to do this!

pkaeding