1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php Tree Menus

Discussion in 'PHP' started by Kyoneko Rose, Jun 6, 2005.

  1. #1
    Alright, on my site (http://puret.org) I currently have my navigation in javascript tree menus. Look at my site if you don't know what I mean.

    What I need help with is if someone can help me fix a problem. I've had a lot of complaints with when you click a link, any menus you had expanded collapse again, so I'm wondering is there either 1) a way to fix this in javascript itself or 2) Can someone help code a PHP tree menu that will work this way?

    Sorry if it's to much to ask^.^
    SEMrush
    Here's the javascript coding used in mine, in case anyone needs it, but truthfully, I think I'd rather have PHP since javascript isn't always the most secure coding form >.<

    
    function Toggle(item) {
       obj=document.getElementById(item);
       visible=(obj.style.display!="none")
       key=document.getElementById("x" + item);
       if (visible) {
         obj.style.display="none";
         key.innerHTML="<img src='folder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
       } else {
          obj.style.display="block";
          key.innerHTML="<img src='textfolder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
       }
    }
    
    function Expand() {
       divs=document.getElementsByTagName("DIV");
       for (i=0;i<divs.length;i++) {
         divs[i].style.display="block";
         key=document.getElementById("x" + divs[i].id);
         key.innerHTML="<img src='textfolder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
       }
    }
    
    function Collapse() {
       divs=document.getElementsByTagName("DIV");
       for (i=0;i<divs.length;i++) {
         divs[i].style.display="none";
         key=document.getElementById("x" + divs[i].id);
         key.innerHTML="<img src='folder.gif' width='16' height='16' hspace='0' vspace='0' border='0'>";
       }
    }
    Code (markup):
    If no one can help me with this, then I have another solution which would include php includes switching, which I don't understand even though it seems simple enough to understand, so if no one knows how to do this, maybe you may be able to help me with teh other thing?

    Thanks in advance!
     
    Kyoneko Rose, Jun 6, 2005 IP
    SEMrush
  2. danpadams

    danpadams Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First off, I would ask how you are storing your data that will be inside the menus and which pages each item links to. Then I am thinking you would want to, when a page is viewed, know which menu item to have it opened to. This would not take into account someone opening to multiple items (unless you use session variables). When you know which menu item to have it open to, you would then want to start by opening it to that item when the page is loaded.

    Most of the menu stuff I have messed with has been in desigining a way to store the data to be used in creating a menu into a database and then also multiple ways, including for a javascript menu and also a sitemap page, to display that information. If you have a question on how I have done it for my site(s), send me a PM. There is a list of my sites under the link in my signature then under clients.
     
    danpadams, Jun 6, 2005 IP