Results 1 to 3 of 3

Thread: help with simpletreemenu with php

  1. #1
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question help with simpletreemenu with php

    1) Script Title: simple tree menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

    3) Describe problem:

    Im a php newbie

    Im working with this simple tree menu script to combine with the mymenu module for the XOOPS Project

    the code is currently working but with only 1 problem

    i have menu like this

    aaaaa
    bbbbb
    -111111
    -222222
    --2.1
    ccccc
    -111111
    ddddd

    all is working fine except the the bbb and ccc is appearing twice : all menu with submenu apearing twice

    like this

    aaaaa
    bbbbb
    bbbbb
    -111111
    -222222
    --2.1
    ccccc
    ccccc
    -111111
    ddddd


    how to fix this

    Tq in advance..and sorry for my english

    my current working code
    PHP Code:
    <ul id="treemenu1" class="treeview">
    <{foreach 
    item=menu from $block}>
        <{if 
    $menu.oul}>
            <{if 
    $menu.level == 0}>
         
            <{elseif 
    $menu.level == 1}>
          
            <{else}>
            <
    ul>
            <{/if}>
        <{/if}>
        
        <{if 
    $menu.oli}>
            <{if 
    $menu.level == 0}>
              <
    li>  
            <{else}>
                <
    li>
            <{/if}>
        <{/if}>
        
        <{if 
    $menu.level == 0}>
            <
    a href="<{$menu.link}>" target="<{$menu.target}>" alt="<{$menu.alt_title}>" title="<{$menu.alt_title}>"><{$menu.title}></a></li>

            <{if 
    $menu.hassub}><li> <{$menu.title}> <ul><{/if}>

        <{else}>
             <
    li><a href="<{$menu.link}>" target="<{$menu.target}>" alt="<{$menu.alt_title}>" title="<{$menu.alt_title}>"><{$menu.title}></a>

             
        <{/if}>

        <{if 
    $menu.close != ''}><{$menu.close}><{/if}>

    <{/foreach}>

    </
    ul>
    <
    script type="text/javascript">
    //ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
    ddtreemenu.createTree("treemenu1"true)
    </script> 


    How can skin know when to open a new <li> or <ul> and when to close it?
    -Mymenus append that information to each menu item, that way you can know if that item
    should be prefixed with a <li> or not.

    This is the composition of an item array:
    [id] => 3 (id of the menu item)
    [pid] => 0 (id of the parent menu item)
    [mid] => 2 (id of the menu package)
    [title] => Home (title of the menu item)
    [alt_title] => Home (alt/title of the menu item)
    [visible] => 1 (visibility of the menu item, it will be 1 for all menus,you can disregard it)
    [link] => http://localhost/xoops-2.4.5/htdocs/ (alt/title of the menu item)
    [weight] => 1 (this is for internal usage of the builder class, you can disregard it)
    [target] => _self (to be used in link target element, it can be _self, _blank, etc..)
    [groups] => Array (holds the groups who can view this link, you can disregard it)
    (
    [0] => 2
    [1] => 3
    )

    [hooks] => Array (holds the hooks available to render the menu, you can disregard it)
    (
    )

    [image] => (image to be used in the link, you can choose not to support it in your skin)
    [css] => (this is inline css for this item, it goes inside <a style="$item.css">)
    [oul] => 1 (IMPORTANT! Open UL -> this menu item requires skin to prepend <ul> open element tag)
    [oli] => 1 (IMPORTANT! Open LI -> this menu item requires skin to prepend <li> open element tag)
    [close] => (IMPORTANT! this holds closing tags, it will automatically generate </li></ul> tags for you)
    [cul] => (IMPORTANT! Close UL -> this menu item requires skin to apend </ul> close element tag, you should use [close] instead, unless you are not suporting multilevel menus)
    [cli] => (IMPORTANT! Close LI -> this menu item requires skin to apend </li> close element tag, you should use [close] instead, unless you are not suporting multilevel menus)
    [hassub] => 1 (informs if this menu item has submenus, 1 for true, 0 for false)
    [level] => 0 (informs the level of nesting of the menu item, 0 is for root, 1 for second level, etc..)
    [down_weight] => 3 (for usage in menu sorting in admin side, you can ignore it)
    [selected] => 1 (IMPORTANT, this tells the skin to highlight this item)
    [topselected] => 1 (Important, this informs the skin that the menu is of level 0(root) and it is selected, you should higlight it)
    )
    Last edited by mulaus; 03-17-2012 at 04:40 PM.

  2. #2
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    example of generated output
    Code:
    <ul id="treemenu1" class="treeview">
                     
     <li>  <a href="http://www.google.com" target="_self" alt="aaaaaa" title="aaaaaa">aaaaaa</a></li>
    
     <li>  <a href="http://www.google.com" target="_self" alt="bbbbb" title="bbbbb">bbbbb</a></li>
    
    <li style="background-image: url(&quot;http://localhost/testing/modules/mymenus/skins/treemenu/closed.gif&quot;);" class="submenu"> bbbbb <ul style="display: none;" rel="closed">
        
      <li> </li>
      
      <li><a href="http://www.google.com" target="_self" alt="111111" title="111111">111111</a></li>
    
     <li></li>
     
     <li style="background-image: url(&quot;http://localhost/testing/modules/mymenus/skins/treemenu/closed.gif&quot;);" class="submenu"><a href="http://www.google.com" target="_self" alt="222222" title="222222">222222</a>
    
    		 
     <ul style="display: none;" rel="closed">
      <li></li>
    
    <li><a href="http://www.google.com" target="_self" alt="211111" title="211111">211111</a> </li>
      </ul>
      
      </li></ul></li>
            
     <li>  <a href="http://www.google.com" target="_self" alt="cccccc" title="cccccc">cccccc</a></li>
    
    </ul>
    
    
    <script type="text/javascript">
    //ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
    ddtreemenu.createTree("treemenu1", true)
    </script>
    just noticed that
    there is an extra <li></li> is that the caused of this ?
    Last edited by mulaus; 03-17-2012 at 04:19 PM.

  3. #3
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    i solved it nevermind....TQ

    PHP Code:
    <ul id="treemenu1" class="treeview">
    <{foreach 
    item=menu from $block}>
        <{if 
    $menu.oul}>
            <{if 
    $menu.level == 0}>
         
            <{elseif 
    $menu.level == 1}>
          
            <{else}>
            <
    ul>
            <{/if}>
        <{/if}>
        
        <{if 
    $menu.oli}>
            <{if 
    $menu.level == 0}>
             <
    li>
            <{else}>
       
            <{/if}>
        <{/if}>
        
        <{if 
    $menu.level == 0}>
          <{if 
    $menu.hassub}> <{else}>  <a href="<{$menu.link}>" target="<{$menu.target}>" alt="<{$menu.alt_title}>" title="<{$menu.alt_title}>">1<{$menu.title}></a></li><{/if}>

            <{if 
    $menu.hassub}><li> <{$menu.title}> <ul><{/if}>

        <{else}>
             <
    li><a href="<{$menu.link}>" target="<{$menu.target}>" alt="<{$menu.alt_title}>" title="<{$menu.alt_title}>"><{$menu.title}></a>

             
        <{/if}>

        <{if 
    $menu.close != ''}><{$menu.close}><{/if}>

    <{/foreach}>

    </
    ul>
    <
    script type="text/javascript">
    //ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
    ddtreemenu.createTree("treemenu1"true)
    </script> 

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
  •