PDA

View Full Version : Sticky Navigation?



ByteRack
02-12-07, 03:22 PM
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\""; ?>>Client Area (clientarea.php)


<ul>
Support (index.php)
<li class="selected">Client Area (clientarea.php)
Knowledgebase (knowledgebase.php)
Support Tickets (supporttickets.php)
Announcements (announcements.php)
Downloads (downloads.php)
Contact Us (contact.php)
[/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.

Matt
02-12-07, 10:26 PM
Why can't you do the following:


if ($_SERVER["PHP_SELF"]=="clientarea.php") { echo "selected"; }

ByteRack
02-12-07, 11:25 PM
Thanks, I'll give that try, my PHP skills are very minimal.

By the way, nice software, I'll be purchasing soon.

ByteRack
02-13-07, 12:07 AM
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}>{$LANG.clientareatitle} (clientarea.php)

Veus
02-13-07, 12:15 AM
Well what youve got is if the if statement returns false, then the tag looks like this:



<li class=>{$LANG.clientareatitle} (clientarea.php)


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}

ByteRack
02-13-07, 12:21 AM
Just tried the above code and I get a blank page now. Is PHP allowed in the .tpl files?

welch
02-13-07, 03:46 AM
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}

ByteRack
02-13-07, 04:50 AM
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.

welch
02-13-07, 08:52 AM
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.

Matt
02-13-07, 11:33 AM
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.[/list]

ByteRack
02-13-07, 01:30 PM
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!

ByteRack
02-13-07, 08:23 PM
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")

ByteRack
02-14-07, 06:10 PM
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}>{$LANG.clientareatitle} (clientarea.php)

I'm still trying to figure out how to make it work with clientarea.php?action=details links.