Topic: PHP Help: User NOT Viewing Topic

I am trying to run some PHP code whenever the user is NOT viewing an individual topic(viewtopic.php). So the code will be run everywhere EXCEPT topics.

Example in English/PHP:

<?php if "User is NOT viewing an individual topic" ?>
<------My block of code--------->
<?php endif; ?>

"My block of code" is a PHP file in my include/user folder, I then call it with <pun_include "mycode.php"> in my main.tpl

I appreciate any help, and if there is a better way of doing this let me know.

Thank You

Re: PHP Help: User NOT Viewing Topic

You might try something like

if(basename($_SERVER['PHP_SELF']) != 'viewtopic.php'}
{
     YOUR CODE HERE
}

Please note that that would be in the file from include/user. You can't put PHP code in main.tpl, which you seem to be suggesting.

Looking for a certain modification for your forum? Please take a look here before posting.

3 (edited by astrojny 2007-06-03 17:21)

Re: PHP Help: User NOT Viewing Topic

Thanks pogenwurst, I am using it in a file from include/user.  I am actually running HTML in "My block of code", not more PHP. I used this as "mycode.php" and it isn't working:

<?php 
if (basename($_SERVER['PHP_SELF']) != 'viewtopic.php') && ($pun_user['is_guest'] ) { 
?>

<---------------MY HTML HERE-------------->

<?php 
} 
?>

I am just getting a blank screen so I am obviously missing something.

Thanks

Re: PHP Help: User NOT Viewing Topic

You're getting a blank page because display_errors is disabled on your server wink
You have a syntax error there. The code should look like this:

<?php 
if (basename($_SERVER['PHP_SELF']) != 'viewtopic.php' && $pun_user['is_guest'])
{ 
?>

<---------------MY HTML HERE-------------->

<?php 
} 
?>

Your if statement was closed too early smile

Re: PHP Help: User NOT Viewing Topic

Thanks Smartys!

Worked like a charm. I knew I had written some bad PHP somewhere smile