active menu

Discussion in 'PHP' started by pitttih, Feb 6, 2008.

Thread Status:
Not open for further replies.
  1. #1
    i want to create tabbed menus for my website. ( with php )
    here is an example, click on one of those menu to see.. : http://citehealth.com

    i want if menu is active.. For example, if I'm on the About Us page of a website, the About Us navigational tab should use a class. (css)

    the code should be something like this :

    <li (start php)class="blah"(end php)><a href="/blah"></a></li>
    Code (markup):
    php code should be inside (start php) and ended at (end php)

    Thanks,
     
    pitttih, Feb 6, 2008 IP
  2. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why not do it like...

    
    <li (start php)class="<?= $class ?>"(end php)><a href="/sometab?class=homepage"></a></li>
    
    Code (markup):
    Then do everything in CSS for whatever the $class variable will hold?

    Highlight it a different color bring to front etc etc.
     
    LittleJonSupportSite, Feb 6, 2008 IP
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    A basic version would be something like this:
    if ($_SERVER['PHP_SELF'] == $currentlink) { $class == "current"; }

    However you would need to either manually set $currentlink, or create some class / function to do it for you.
     
    m0nkeymafia, Feb 6, 2008 IP
  4. pitttih

    pitttih Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for your reply!
    but can you explain me a little more ?
    I'm newbe in php.

    can i use this like this without anything extra?

    <li <?php if ($_SERVER['PHP_SELF'] == $currentlink) { $class == "current"; }; ?><a href="/blah"></a></li>

    can you write a full solution for me please?

    please help ..:confused:
     
    pitttih, Feb 6, 2008 IP
  5. pitttih

    pitttih Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    can anyone help me please ?!:confused:
     
    pitttih, Feb 8, 2008 IP
Thread Status:
Not open for further replies.