Log in

View Full Version : quick template question


matbennett
05-30-2007, 03:19 PM
I'm coding an add-on for vbulletin at the moment, but stuck on something really basic. (typical... all the tricky bits are working).



I just need to check whether a string contains a certain value. I've already pulled an additional variable in on showthread.php ($userbadge) and just want to do the equivalent of



if (stristr($post['haystack'],"needle"){

// do something

}



Just not very familiar with vbulletin templates, so a pointer at this stage would be really helpful.

from what I have managed to find out, I think that conditions only let you apply very limited PHP functions. One solution would be to add to the functions that can be used - can this be done?



Thanks.

WetWired
05-31-2007, 05:26 PM
It would be <if condition="stristr($post['haystack'],'needle')"></if>, except that stristr is not on the list of functions allowed.
http://www.vbulletin.com/docs/html/main/functions_in_conditionals
You can add to the list of allowed functions in a plugin, like in the attached example, however, it's best to first see if you can do the same thing with an already allowed function.