Back to vBulletin Tips & Tricks

Perform simple calculations inside templates!
by Lea Verou 23 Aug 2008

I was quite excited to find this out!

Have you ever wanted to make a simple calculation for a template, like an addition or subtraction? Personally, I needed this many times and most of them I created a plugin for that. Today I discovered that that is unecessary. You can use the conditional to make simple calculations. For instance, lets suppose you want to display somewhere the userid of the current user, incremented by one. You could do this:
HTML Code:
<if condition="$nextid = $bbuserinfo['userid']+1"></if>
The next userid is $nextid.
This will display as (given that the userid of the user viewing is 1):
The next userid is 2.
Of course the userid example is very simple, just to make you understand what I'm talking about.

Let me know if it helped you!

vblts.ru supports vBulletin®, 2022-2024