From c9e2cb82f06d9ec58992070db26f61ea0369a34d Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 15 Jan 2018 15:55:20 -0500 Subject: [PATCH] using separate nav menus instead of one topbar changing the topbar to use separate nav menus --- lib/navigation.php | 121 ++++++++++++++++++++++++++++++-------------- sections/header.php | 4 +- 2 files changed, 85 insertions(+), 40 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index 7f5eb6f..3f6cfb5 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -1,41 +1,59 @@ 'Site Navigation', + 'boards' => 'boards-committees', + 'departments' => 'departments-services', + 'township' => 'township-resources', + 'calendar' => 'township-calendar', 'mobile-menu' => 'Off Canvas', 'alt-menu' => "How Do I...", - )); -if ( ! function_exists( 'glm_theme_members_only' ) ) { - function glm_theme_members_only($location) { - echo ''; - } -} /** * Top Bar */ if ( ! function_exists( 'glm_theme_top_bar' ) ) { - function glm_theme_top_bar($location) { - wp_nav_menu(array( - 'container' => false, // remove nav container - 'container_class' => '', // class of container - 'menu' => '', // menu name - 'menu_class' => '', // adding custom nav class - 'theme_location' => $location, // where it's located in the theme - 'before' => '', // before each link - 'after' => '', // after each link - 'link_before' => '', // before each link text - 'link_after' => '', // after each link text - 'depth' => 2, // limit the depth of the nav - 'fallback_cb' => false, // fallback function (see below) - 'walker' => new Glm_Theme_Top_Bar_Walker() - )); - } + function glm_theme_top_bar() { + echo ''; + } +} +/** + * Alt Menus + */ +if ( ! function_exists( 'glm_theme_menus' ) ) { + function glm_theme_menus($location) { + echo ''; + } +} + +function glm_get_top_bar_nav_menu( $theme_location ) +{ + $menu = wp_nav_menu(array( + 'echo' => false, // don't echo + 'container' => false, // remove nav container + 'container_class' => '', // class of container + 'menu' => '', // menu name + 'menu_class' => '', // adding custom nav class + 'theme_location' => $theme_location, // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 2, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new Glm_Theme_Top_Bar_Walker() + )); + return preg_replace( array( '%^]*>%', '%$%' ), '', $menu ); } + /** * Mobile off-canvas */ @@ -175,10 +193,39 @@ function glm_get_menu_options() * @return void */ function glm_side_menu($mobile = false) { + global $post; + $sideMenu = $allMenu = $pageMenuId = array(); - if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) { - $menu = wp_get_nav_menu_object($locations['top-bar']); + +// echo $post->ID; +// if (($locations = get_nav_menu_locations()) && isset($locations['top-bar-1'])) { +// $menu = wp_get_nav_menu_object($locations['top-bar-1']); +// } + if(is_page(195) || 195 == $post->post_parent || is_in_tree(195)){ + if (($locations = get_nav_menu_locations()) && isset($locations['boards'])) { + $menu = wp_get_nav_menu_object($locations['boards']); + } + } + + if(is_page(197) || 197 == $post->post_parent || is_in_tree(197)){ + if (($locations = get_nav_menu_locations()) && isset($locations['departments'])) { + $menu = wp_get_nav_menu_object($locations['departments']); + } + } + + if(is_page(199) || 199 == $post->post_parent || is_in_tree(199)){ + if (($locations = get_nav_menu_locations()) && isset($locations['calendar'])) { + $menu = wp_get_nav_menu_object($locations['calendar']); + } + } + if(is_page(201) || 201 == $post->post_parent || is_in_tree(201)){ + if (($locations = get_nav_menu_locations()) && isset($locations['township'])) { + $menu = wp_get_nav_menu_object($locations['township']); + } + + } + $menu_items = wp_get_nav_menu_items($menu->term_id); foreach ((array) $menu_items as $key => $menu_item) { $sideMenu[$menu_item->menu_item_parent][] = $menu_item; @@ -208,9 +255,9 @@ function glm_side_menu($mobile = false) { // If the first element is title [Tabs] then this is a uber menu // custom item and we need to get the subs under that menu item // instead ($sideMenu[$subs[0]->ID]) - if ($subs[0]->title == '[Tabs]') { - $subs = $sideMenu[$subs[0]->ID]; - } +// if ($subs[0]->title == '[Tabs]') { +// $subs = $sideMenu[$subs[0]->ID]; +// } } else if ($thisPageMenuParent) { $pageHead = $allMenu[$thisPageMenuParent]; // get the subs for $thisPageMenuParent @@ -220,7 +267,7 @@ function glm_side_menu($mobile = false) { // get Main level $subs = $sideMenu[0]; } - } + if ($mobile) { echo '