PDA

View Full Version : Template if conditions


stevegrant
12-04-2009, 06:03 AM
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
12-04-2009, 01:39 PM
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
12-04-2009, 02:57 PM
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...