how to make a navigation with an active marking?

Discussion in 'HTML & Website Design' started by HDaddy, Feb 19, 2008.

  1. #1
    Sorry for the bad title, but didn´t know how to explain it.

    So i´m asking how do you do navigations where you have a different color for the page you are in. For example if you are on a link page you have the "LINK"
    part of the navigation highlited and other are different color. I´m especially interested in tabsmenus. So if you have tutorial links, please post them.

    Thanks in advance !
     
    HDaddy, Feb 19, 2008 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    I usually put a class on the 'current' menu item called... you guessed it - current.

    <ul id="mainMenu">
    	<li><a href="#>Home</a></li>
    	<li class="current"><a href="#>Articles</a></li>
    	<li><a href="#>Forums</a></li>
    	<li><a href="#>Links</a></li>
    	<li><a href="#>Contact</a></li>
    </ul>
    Code (markup):
    Then you just vary it from page to page. Usually I actually set that class server-side by comparing a variable... in php for example I'd just set $currentPage='articles'; - and then in my header.inc.php I'd have the code as:

    echo '
    <ul id="mainMenu">
    	<li',($currentPage=='home' ? 'class="current" : ""),'>
    		<a href="#>Home</a>
    	</li>
    	<li',($currentPage=='articles' ? 'class="current" : ""),'>
    		<a href="#>Articles</a>
    	</li>
    	<li',($currentPage=='forums' ? 'class="current" : ""),'>
    		<a href="#>Forums</a>
    	</li>
    	<li',($currentPage=='links' ? 'class="current" : ""),'>
    		<a href="#>Links</a>
    	</li>
    	<li',($currentPage=='content' ? 'class="current" : ""),'>
    		<a href="#>Contact</a>
    	</li>
    </ul>
    ';
    Code (markup):
     
    deathshadow, Feb 19, 2008 IP
  3. HDaddy

    HDaddy Active Member

    Messages:
    287
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks deathshadow...I´m not familiar with php at the moment, but i just used SSI in one my sites..Could you set a similar example with SSI commands, or is it possible?

    Thanks
     
    HDaddy, Feb 19, 2008 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Uhm, php is a form of SSI - at least in most apache installations it's included in the server and does not use the common gateway interface - "SSI" by itself is a little vague... do you mean SHTML? I think I've seen some people call it that.

    If so... gah, been a while, let me dust out the cobwebs in me noggin'. To set the variable:

    <!--#set var="currentPage" value="article" -->

    Then for the actual page construction... gah, I can't remember the if structure for SHTML... I've not given it serious use in at least six or so. I know it's going to be a big fat bloat of if and endif statements...
     
    deathshadow, Feb 19, 2008 IP
  5. HDaddy

    HDaddy Active Member

    Messages:
    287
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Ok, thanks for the effort. I just used SSI for the menu and the footer in one of my websites so that i wouldn´t have to change all the pages if i wanted a new link in the menu, so that´s my experience in SSI. I guess i could try to google for a solution. Or i could try your php example in one of my testsites.
     
    HDaddy, Feb 19, 2008 IP