I am editing the header.html file in the /templates folder - what I would like to do is check if the URL is either /signup.php or /member.php and then style the menu current state accordingly. Here is the script: PHP: <?php $path = $_SERVER['PHP_SELF']; $file = basename($path, ".php"); // $file is set to "index" ?> <?php if($file == 'member'){ echo 'current'; } ?> <?php if($file == 'signup'){ echo 'current'; } ?> The first portion works fine but the IF statements do not, seems to be a Smarty error. Anyone know the correct syntax for aMember?
PHP: <?php $path = $_SERVER['PHP_SELF']; $file = basename($path, ".php"); // $file is set to "index" echo $file; //Check variable contents exit; ?> <?php if($file == 'member.php'){ echo 'current'; } ?> //added .php <?php if($file == 'signup.php'){ echo 'current'; } ?> //added .php Firstly I would always suggest, if something fails to work is check what a variable ACTUALLY contains and have added the echo $file as a check. With your actual code you have joined the 'path' to '.php' to form 'member.php' or 'signup.php' so the if will always fail!
Hi thehpmc, thanks, I already had checked the output and it contains either "member" or "signup" rather than member.php or signup.php. aser, thanks for the correct Smarty usage - I now have this which works correctly on a list menu item: PHP: {php} $path = $_SERVER['PHP_SELF']; $file = basename($path, ".php"); //$file is set to member or signup {/php} <ul id="nav"> <li><a href="domain.com/members/member.php" {php} if($file == 'member'){ echo 'class="current"'; } {/php} title="My account page">Login & My Account</a></li> <li><a href="domain.com/members/signup.php" {php} if($file == 'signup'){ echo 'class="current"'; } {/php} title="Signup ">Signup</a></li> Hope it helps someone else...thanks for your help!