ByteRack Posted February 12, 2007 Share Posted February 12, 2007 Any way to make this happen? I would usually put something like this at the top of each page to identify the page. <?php $thisPage="clientarea";?> Then add this piece of coded to the link so it's highlighted when your on that particular page. <li <?php if ($thisPage=="clientarea") echo " class=\"selected\""; ?>>[url="clientarea.php"]Client Area[/url] <ul> [*][url="index.php"]Support[/url] <li class="selected">[url="clientarea.php"]Client Area[/url] [*][url="knowledgebase.php"]Knowledgebase[/url] [*][url="supporttickets.php"]Support Tickets[/url] [*][url="announcements.php"]Announcements[/url] [*][url="downloads.php"]Downloads[/url] [*][url="contact.php"]Contact Us[/url] [/list] Is there anything pre-existing I could hook into to identfy what page the user is on. I realize I can't place <?php $thisPage="clientarea";?> on each page. I also thought of using the body tag, but didn't seem possible either. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted February 12, 2007 WHMCS CEO Share Posted February 12, 2007 Why can't you do the following: if ($_SERVER["PHP_SELF"]=="clientarea.php") { echo "selected"; } 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 Thanks, I'll give that try, my PHP skills are very minimal. By the way, nice software, I'll be purchasing soon. 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 How would I put this into the header.tpl correctly? I tried putting it between {php}{/php} and nothing. Just leaves it blank. <li class={php} if ($_SERVER["PHP_SELF"]=="clientarea.php") { echo "selected"; } {/php}>[url="clientarea.php"]{$LANG.clientareatitle}[/url] 0 Quote Link to comment Share on other sites More sharing options...
Veus Posted February 13, 2007 Share Posted February 13, 2007 Well what youve got is if the if statement returns false, then the [*] tag looks like this: <li class=>[url="clientarea.php"]{$LANG.clientareatitle}[/url] Which is wrong. Why dont you do: {php} if($_SERVER["PHP_SELF"] == "clientarea.php") { echo "<li class=\"selected\"><a href=\"clientarea.php\">{$LANG.clientareatitle}</a>"; } else { echo "[*]<a href=\"clientarea.php\">{$LANG.clientareatitle}</a>"; } {/php} 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 Just tried the above code and I get a blank page now. Is PHP allowed in the .tpl files? 0 Quote Link to comment Share on other sites More sharing options...
welch Posted February 13, 2007 Share Posted February 13, 2007 PHP is allowed but i appears you are pulling TPL variables which would require another command. Try the following code: {php} if ($_SERVER["PHP_SELF"] == "/clientarea.php") { echo "<li class=\"selected\"><a href=\"clientarea.php\">Client Area</a>"; } else { echo "<a href=\"clientarea.php\">Client Area</a>"; } {/php} 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 Thanks guys, but I still can't get it working. I keep getting blank pages when I use the above code. I think the curly brackets in the PHP code are interefering with the smarty templates. 0 Quote Link to comment Share on other sites More sharing options...
welch Posted February 13, 2007 Share Posted February 13, 2007 I was able to get the following code to work in my test bed. Try the following: configuration.php add $display_errors = "on"; and on the page your editing this on add {debug} at the top. should help you out some. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted February 13, 2007 WHMCS CEO Share Posted February 13, 2007 Thanks guys, but I still can't get it working. I keep getting blank pages when I use the above code. I think the curly brackets in the PHP code are interefering with the smarty templates. You definately can use PHP code in the templates and the curly brackets inside {php} and {/php} tags will not cause errors. A blank page will mean there is an error in the code you have entered. 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 You guys rule! There were errors or blank spaces from copying the code from the forum. I re-typed and it worked perfect. Live example, still under construction: w w w .byterack.net/support/clientarea.php Here's what ended up working for me: {php} if ($_SERVER["PHP_SELF"] == "/support/clientarea.php") { echo "<li class=\"selected\"><a href=\"clientarea.php\">Client Area</a>"; } else { echo "[*]<a href=\"clientarea.php\">Client Area</a>"; } {/php} Is there any way to use {$LANG.clientareatitle} so language switching still works. I tried to use it the above code and got a blank page. Thanks again! 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 13, 2007 Author Share Posted February 13, 2007 One more question, it doesn't work on the Client links once I'm logged in. For example this link: clientarea.php?action=details if ($_SERVER["PHP_SELF"] == "/support/clientarea.php?action=details") 0 Quote Link to comment Share on other sites More sharing options...
ByteRack Posted February 14, 2007 Author Share Posted February 14, 2007 I ended up using this, works perfect and allows {$LANG.clientareatitle} to be used. <li {if $smarty.server.PHP_SELF == "/support/clientarea.php"}class="selected"{/if}>[url="clientarea.php"]{$LANG.clientareatitle}[/url] I'm still trying to figure out how to make it work with clientarea.php?action=details links. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.