I just took over working on a site that has been coded in php. the menu is using an array // 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; } PHP: with the array inputs looking as: $menu[] = array( 'title' => 'Activities', 'href' => 'activities.php' ); PHP: I would like to make this a drop down Parent: Activities Child 1: Summer Child 2: Winter is this doable? and I apologize in advance for posting so much code, i've disected most of the rest of it, just not this part.
Not sure why it's not working. But one thing caught me eye. if (isset($item['li_class']) && !empty($item['li_class'])) { $li_class .= (!empty($li_class)) ? ' ' . $item['li_class'] : $item['li_class']; } Code (markup): Checking if a variable is set, and not empty is the same thing. Just go with one or the other.
I suppose hierarchy... what i'm after is something like you see at subject2homeinspections.com (which i know is a joomla site cuz i'm the developer for it) I'm not really a coder so i'm a bit lost, I did not do the site originally, and will most likely have to get some of the coding validated. any help is greatly appreciated.
oh, organicCyborg the menu works as it is, i just want to expand it and make it more functional if possible.
I posted this in another forum and got this response: $menu[] = array( 'title' => 'Activities' ,'href' => 'activities.php' ,'children' => array( 0 => array( 'title' => 'Subitem 1' ,'href' => 'sub1.php' ) ,1 => array( 'title' => 'Subitem 2' ,'href' => 'sub2.php' ) ) ); // then in your menu function if(array_key_exists('children', $item) && !empty($item['children'])) $output .= get_menu($item['children']); [PHP] though the person who posted it wasn't quite sure if it would work. PHP: