SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question li class="selected" NOT selecting (quick question)

    Hello am workin on a text portfolio page with some php.

    Anyway i have a little li navigation to control it all here anyway the top 2 links work (even though php not working yet) but when you click on the second one so it is selected the colour doesn't change. It still remains on the top link, even though thats not the one selected?

    How does the whole 'selected' class work i thought it was when the address changes?

    I dont get it

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you define that class in your css?

  3. #3
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But your address doesn't change. You're still in portfoliotest.php and it uses the html of this page which puts the selected class in the first li. It doesn't automatically change, you need to implement this behaviour in your php code.
    Dan G
    Marketing Strategist & Consultant

  4. #4
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No cmuench i didn't define the class i don't know how to do that.

    How can i implement the behavior in the php, c2uk?

    I shall post this question in the php section as well if that is ok?

  5. #5
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question li class="selected" NOT selecting (php question)

    I posted the below question in the css section however, the good people over there said i would have to:
    Quote Originally Posted by c2uk
    But your address doesn't change. You're still in portfoliotest.php and it uses the html of this page which puts the selected class in the first li. It doesn't automatically change, you need to implement this behaviour in your php code.
    Original post.
    Hello am workin on a text portfolio page with some php.

    Anyway i have a little li navigation to control it all here anyway the top 2 links work (even though php not working yet) but when you click on the second one so it is selected the colour doesn't change. It still remains on the top link, even though thats not the one selected?

    How does the whole 'selected' class work i thought it was when the address changes?

    I dont get it
    Hope that all makes sense.

    Cheers

  6. #6
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    London
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The CSS folk are right: you need to "move" the class="selected" to the element that you wish to be highlighted.

    Doesn't look like you (yet) have anything that could tell the page which to highlight. This is often done with a query string, though that's certainly not the only way.

  7. #7
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    London
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops... I looked again: you are using querystring to define the pages. So it's a case of testing for $_GET['page'] and placing the class="selected" accordingly.

  8. #8
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I assumed you know php since you are using it, it's not a big deal really but it would be helpful if you could provide your php code.
    Dan G
    Marketing Strategist & Consultant

  9. #9
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know a very basic php and a friend of mine helped me with this php.

    Here is the code which is in the portfoliotest.php page on the left hand side of the page.

    PHP Code:
    <?php
    $page 
    $_GET['page'];
    if (
    $page == "") {
        
    }else{
        include (
    "portfolio/portfoliotest_inc_$page.php");
    }
    ?>
    If finds the pages saved in portfolio folder named portfoliotest_inc_page1.php etc i am sure your aware more than i am.

    Where should i add the selected to that?

  10. #10
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    377
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    edit

    threads put together
    Last edited by Jezthompson12@nt; Jul 9, 2006 at 05:08.

  11. #11
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    London
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a couple of ways you could approach this.

    The first would be to generate your menu from scratch each time. You'd typically be looping through a set of values, testing for the "current page" each time.

    One alternative is to have the menu fixed, but to bury a dynamic element in each item:
    HTML Code:
    <ul class="portfolio">
    <li <?php echo ($_GET['page']=='axholme'?'class="selected"':'')?> ><a href="portfoliotest.php?page=axholme">test site </a></li>
    <li <?php echo ($_GET['page']=='studentLets'?'class="selected"':'')?>><a href="portfoliotest.php?page=studentLets">test site1 </a></li>
    
    </ul>


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
  •