PDA

View Full Version : Coding noob having trouble with <IF> tag


TeddyKGB
01-16-2007, 03:14 AM
I am looking at using the <IF> statement in one of my templates and I am having trouble, hoping somone here can assist.

I am looking to have on navbar button do 2 different things depending on the current page. So it would look something like this

<if CURRENT PAGE="index.php">
<td align="left" valign="top" width="62" height="69"><a href="$vboptions[forumhome].php$session[sessionurl_q]" accesskey="1"><img src="$stylevar[imgdir_misc]/nav_home.gif" width="62" height="69" border="0" alt="" /></a></td>
<else />
<td align="left" valign="top" width="62" height="69"><a href="/index.php" accesskey="1"><img src="$stylevar[imgdir_misc]/nav_home.gif" width="62" height="69" border="0" alt="" /></a></td>
</if>

Basically if you are on /forumindex.php the button will take you to /index.php and vice versa. Is this possible and if so what is the proper syntax of the condition (highlighted in red) that I need to use?

Thanks in advance

calorie
01-16-2007, 03:22 AM
In the vB PHP files you will find constants:

// in the index.php file near the top
define('THIS_SCRIPT', 'index');

// in the showthread.php file near the top
define('THIS_SCRIPT', 'showthread');

Use THIS_SCRIPT in template conditionals:

<if condition="THIS_SCRIPT == 'index'">
on forum index page
<else />
not on forum index page
</if>

<if condition="THIS_SCRIPT == 'showthread'">
on forum showthread page
<else />
not on forum showthread page
</if>

TeddyKGB
01-16-2007, 03:32 AM
Brilliant!

Thank you SO much calorie. Worked like a charm.