PDA

View Full Version : A PHP if statement that works outside of vbulletin but not in my header


VVV Mars VG
12-02-2009, 06:36 PM
I have this statement

<?php
if (strpos ($_SERVER["PHP_SELF"],'showthread.php')!==false) {
echo "Thread";
} else {
echo "Something else";
}
?>

I don't have much experience with PHP so when I first came up against an error I switched over to using a stand alone file outside of vbulletin but still in the same directory and it worked fine.

This is the error I'm getting

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in XXXX/forum/includes/adminfunctions_template.php(3939) : eval()'d code on line 16

Does anyone know why this doesn't work within vbulletin? And perhaps what I should be doing instead.

Thanks.

Paul M
12-02-2009, 09:59 PM
You cannot put php code in templates.

Adrian Schneider
12-02-2009, 10:01 PM
Use this, <if condition="THIS_SCRIPT == 'showthread'">
Thread
<else />
Something Else
</if>

VVV Mars VG
12-03-2009, 04:37 AM
Thanks guys that worked perfectly. I didn't realise I couldn't put PHP code into the templates.

Thanks again.