vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   A PHP if statement that works outside of vbulletin but not in my header (https://vborg.vbsupport.ru/showthread.php?t=229363)

VVV Mars VG 12-02-2009 06:36 PM

A PHP if statement that works outside of vbulletin but not in my header
 
I have this statement

Code:

<?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

Code:

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,
Code:

<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.


All times are GMT. The time now is 06:20 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01111 seconds
  • Memory Usage 1,710KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete