PDA

View Full Version : Template if conditions


stevegrant
04 Dec 2009, 08:03
I'm a bit stuck on a conditional statement - basically, I've got an array of UNIX timestamps that I want to compare with the current UNIX timestamp - generated from time():

The two values I want to compare are:
{vb:raw current_timestamp}
{vb:raw times.this_time}

but the following (and various combinations thereof) doesn't work:
<vb:if condition="{vb:number current_timestamp} < {vb:number times.this_time}">
...
</vb:if>

The error message displayed is:

The following error occurred when attempting to evaluate this template:

Parse error: syntax error, unexpected '{' in /www/vb4/upload/includes/adminfunctions_template.php(4516) : eval()'d code on line 17

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.

Any ideas as to how I can perform this (relatively simple!) comparison?

Lynne
04 Dec 2009, 15:39
The variable syntax in an if statement in vb4 is the same as for vb3. So something like:

<vb:if condition="$current_timestamp < $times['this_time']">
...
</vb:if>

stevegrant
04 Dec 2009, 16:57
Ah ok, thanks - will try that this evening :)

This is my first attempt at creating extra pages/apps for vB - the forum on my site has always been standalone from the rest of the site, which is WordPress-based. Not for long, though...