Array Menu needs child items

Discussion in 'PHP' started by Ducimus, Nov 12, 2009.

  1. Ducimus

    Ducimus New Member

    Joined:
    Nov 12, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Help please.
    I am a programming dummy who took over working on this website for a friend. the original programmer built it all in php which is great, i've figured out almost all of it except the menu array.

    I have 3 blocks of related code:
    CSS
    Code:
    [COLOR=Purple]** Links
      */
      a { text-decoration: none; color: #6e7549; }
    a:hover { text-decoration: none; color: #ccc;}[/COLOR]
     [COLOR=Purple]#main-menu {
      margin-left: 220px;
      margin-right: 50px;
      height: 93px;
      }[/COLOR]
    [COLOR=Purple] #main-menu ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
      text-align: right;
      padding-top: 45px;
      }
      #main-menu li {
      display: inline;
      padding: 20px 10px 3px 10px;
      border-right: 1px solid #CCC;
      }
      #main-menu li ul {
      margin:0px;
      padding:0px;
      display:none;
      position:absolute;
      left:0px;
      top:20px;
      background-color:#000;
      }
      #main-menu li.last {
      border-right: 0px none;
      }
      #main-menu li a {
      color: #000;
      /*text-transform: uppercase;*/
      font-variant: small-caps;
      }
      #main-menu li ul a {
      color: #000;
      /*text-transform: uppercase;*/
      font-variant: small-caps;
      }
      #main-menu li a:hover {
      color: #6e7549;
      }
      #main-menu li ul a:hover {
      color: #6e7549;
      }[/COLOR]
    From the functions php file:
    PHP:
    // Get a menu based on an array
            //
            
    function get_menu($menu = array(), $ulclass ''$is_main_menu false) {
            global 
    $menu_selected;
            
    $output '';
            if (empty(
    $menu)) {
            return 
    $output;
            }
            
    $output .= '<ul' . (!empty($ulclass) ? (' class="' $ulclass '"') : '') . '>';
            foreach(
    $menu as $item) {
            if (!
    $is_main_menu || !isset($item['hide_in_main']) || !$item['hide_in_main']) {
            
    $li_class = (isset($item['sub']) && !empty($item['href']) ? ('dir') : '');
            if (isset(
    $menu_selected) && !empty($menu_selected) && $menu_selected == $item['href']) {
            
    $li_class = (!empty($li_class)) ? $li_class ' selected' 'selected';
            }
            if (isset(
    $item['li_class']) && !empty($item['li_class'])) {
            
    $li_class .= (!empty($li_class)) ? ' ' $item['li_class'] : $item['li_class'];
            }
            
    $output .= '<li' . (!empty($li_class) ? ' class="' $li_class '"''' ) . '>';
            
    $output .= '<a';
            if (isset(
    $item['href']) && !empty($item['href'])) {
            
    $output .= ' href="' $item['href'] .'"';
            }
            if (isset(
    $item['title']) && !empty($item['title'])) {
            
    $output .= ' title="' $item['title'] .'"';
            }
            if (isset(
    $item['class']) && !empty($item['class'])) {
            
    $output .= ' class="' $item['class'] .'"';
            }
            if (isset(
    $item['target']) && !empty($item['target'])) {
            
    $output .= ' target="' $item['target'] .'"';
            }
            
    $output .= '>';
            if (isset(
    $item['title']) && !empty($item['title'])) {
            
    $output .= $item['title'];
            } else if (isset(
    $item['href']) && !empty($item['href'])) {
            
    $output .= $item['href'];
            }
            
    $output .= '</a>';
            if (isset(
    $item['sub']) && !empty($item['sub'])) {
            
    $output .= get_menu($item['sub'], $ulclass);
            }
            
    $output .= '</li>';
            }
            }
            
    $output .= '</ul>';
            return 
    $output;
            }
         
    //
    and from the config php file:
    PHP:
    // Site Menu
            //
            
    $menu[] = array(
            
    'title' => 'Home',
            
    'href' => 'index.php'
            
    );
            
    $menu[] = array(
            
    'title' => 'Activities',
            );
            
    $menu[] = array(
            
    'title' => 'Winter Activities',
            
    'href' => 'wactivities.php'
            
    );
            
    $menu[] = array(
            
    'title' => 'Image Gallery',
            
    'href' => 'gallery.php'
        
    );
    I'm just trying to make child items (second level). the css validates as correct (though because it's right, it doesn't mean it's entirely right for this application) so i just need assistance in working the second level into the array.


    Any assistance I can get would be so greatly appreciated.
    TIA
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice