Special Link Property For Current Page?

Discussion in 'HTML & Website Design' started by Mr. Damnation, Jul 27, 2008.

  1. #1
    I hope I'm as descriptive as I can be in the topic, but I have a question and I don't know how to go about it.

    In my design I plan to have a special image for the page you are currently on. For a simpler example, take a navigation bar that the links are red. When you are on the "home" page or any of the other pages that correspond to the links in the bar, the link is blue, letting you know that is the page you are on.

    Does HTML have that property built in? I see it all the time and think it must be much more simple than what I'm thinking.

    I'm thinking to do a PHP Case-Switch set that $_GETS the page and then finds the corresponding link and changing the CSS property to give it a special image. But I think that's way too complicated for what I want. I think there is a much easier way than that, like a simple AJAX script or something.

    Can anyone give me advice?
     
    Mr. Damnation, Jul 27, 2008 IP
  2. Submerged

    Submerged Active Member

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    What I've done with things like that is set up code like:
    <?
    // Part of the individual page
    $page = "index";
    include ('header.php');
    
    // The rest is part of an included file, header.php
    $pages[1] = "index";
    $pages[2] = "gallery";
    $pages[3] = "sitemap";
    $pages[4] = "contact";
    
    for ($round=1;$round<=4;$round++)
    {
        if ($pages[$round] == $page)
        { echo "<img src='red$pages[$round]'>";}
        else
       { echo "<img src='blue$pages[$round]'>";}
    }
    PHP:
    So basically, the page it was on (you would identify $page on each page) would be red and the others blue based on the filename. This is assuming that this whole code is part of a header file or something included; otherwise just hard-code it in.

    Did that help?
    -Alex

    P.S. I didn't test the code there, so there might be a slight syntax error somewhere.
     
    Submerged, Jul 27, 2008 IP
  3. Mr. Damnation

    Mr. Damnation Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, I kind of came to that conclusion, lol. I was just hoping there was a simpler way.
     
    Mr. Damnation, Jul 27, 2008 IP