SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Current Class not echoing page

    I created a psuedo class of current to display over the menu to show a user where they are at. However when implementing the code it seems the server is only catching the current page on index and not contact us. The other pages are not up yet. I am wondering maybe if I did something incorrect in the coding.

    This is the menu code.

    Code:
     
            <ul>
        <li <?php if($pageOn == 'index.php'){?> class="current"<?php }?>>
                <a href="index.php">Home</a> </li>
              <li>
                <a href="#">Programs</a> </li>
              <li>
                <a href="#">Partnerships</a> </li>
              <li>
                <a href="#">Donate</a> </li>
              <li <?php if($pageOn == 'contact.php'){?> class="current"<?php }?>>
                <a href="contact.php">Contact Us</a> </li>
         
            </ul>
    This is the PHP at the top of the page directing $pageOn.

    Code:
    <?php
    $pageOn = basename($_SERVER['PHP_SELF']);
    $mItem = $pageOn;
    ?>
    Site URL: http://pinkandgreenfoundation.org/test/index.php

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    I don't see the "current" class being added on the home page either.

    What is the value of $pageOn ?

    Code php:
    var_dump($pageOn);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •