views:

314

answers:

3

I'd like to use PHP in a vBulletin style/skin, yet when I do so, the PHP doesn't work.

By 'not work', I mean it's treated just as plain text. And if you look in the code you can see the PHP code (hidden, by Firefox - which is the behaviour you get if you put PHP code on a plain html page)

http://vapurl.com/h0kp3fqr8c - view source, and you'll see what I mean.

+1  A: 

Assuming you're entering the correct PHP syntax, this may be occurring if you're trying to use any of the standard output methods.

If you are trying to use echo, print or any other similar output function, try wrapping all of your included PHP within ob functions.

Example:

ob_start();
   //PHP code I want to run goes here
   echo "Test this works?";
ob_end_clean();
KushalP
Thanks for the reply, but this still didn't work unfortunately.
Tom
+2  A: 

You can't stick random PHP into the vBulletin templating system; it gives you some simple branching options in the form of

<if condition="$somevariable === $someothervariable">
    some text or HTML to be displayed
</else>
    some other text or HTML to be displayed
</if>

A good explanation of how the template conditional system works can be found in the vBulletin manual here.

Your short url appears to have expired, but if the code you wish to include is more complicated than that, you need to start looking into vBulletin hooks and plugins.

Ross Duggan
+1  A: 

hooks /plugins are the best way of manipulating data before displaying it in the template. You can add as much php as you want in a plugin and then modify the template to output the results.

JoshHighland