SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Create a menu persistence library

    I am starting a new post following inactivity on this thread http://www.sitepoint.com/forums/showthread.php?t=451068

    Keeping a menu in the same state it was in before being clicked is incredibly frustrating to develop. There seem to be a plethora of examples out there but none that I can adapt to fit my needs. This seems to be a common task but there is no standard implementation of session cookies to handle this. I propose as a community we try to create a library of functions that can handle this task. Using unordered lists for the creation of the menu, css for the styling, and javascript to handle the expand/contract and persistence. Does anybody want to help? I am a day into the project and need to solve it for a client. Regardless, when I get this figured out I will share it with everybody b/c it should not be this hard.

    Thank you

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I am having trouble figuring out what to store in the cookie. Once I get that figured out I'll let you know. I hope to complete the project today.
    From the other thread. Give each menu section an id. When something is clicked, store the item's ID in the cookie. PHP reads the cookie and applies the proper CSS accordingly to make the menu be open when the page loads. For instance, if the cookie reads $_COOKIE['id'] = "A" then the item with id="A" can be given the class "expanded" and so it will appear expanded. It could be extended to work for multiple ids.

    It's actually that simple - Nolan's script just changes class names - .treeopen and .treeclosed. So I wouldn't call this a library, just a small addition to Nolan's script. And if you don't want to do this with PHP, you could just as well do it with JS alone onload or by document.write()ing it into the <head>.


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
  •