Update menus
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 8 Jan 2015 15:30:38 +0000 (10:30 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 8 Jan 2015 15:30:38 +0000 (10:30 -0500)
only show the main level
and in mobile view show the home page also

functions.php
header.php
sidebar.php

index cd789cb..a9ff8b3 100755 (executable)
@@ -28,9 +28,11 @@ add_action( 'widgets_init', 'arphabet_widgets_init' );
  *
  * Grab the top level pages and their sub pages as the main navigation
  */
-function glm_page_menu($parent = 0, $class = '')
+function glm_page_menu($parent = 0, $class = '', $mainOnly = false, $includeHomePage = false)
 {
-    $frontPageId  = get_option('page_on_front');
+    $frontPageId  = ($includeHomePage)
+    ? ''
+    : get_option('page_on_front');
     $parents = array();
     $pages = get_pages(array(
         'post_type'   => 'page',
@@ -44,7 +46,7 @@ function glm_page_menu($parent = 0, $class = '')
     echo '<ul'.(($class)?' class="'.$class.'"':'').'><!-- begin -->'."\n";
     foreach ($pages as $page) {
         $childs = get_pages('child_of=' . $page->ID);
-        if (count($childs) > 0) {
+        if (count($childs) > 0 && !$mainOnly) {
             echo '<li class="has-dropdown">'."\n";
             echo '<a href="'.get_permalink($page->ID).'">'.$page->post_title.'</a>'."\n";
             echo glm_page_menu($page->ID, 'sub-menu dropdown');
index f67970a..75c9d3e 100755 (executable)
@@ -56,7 +56,7 @@
                 </section>
             </nav>
                 <aside class="left-off-canvas-menu">
-                    <?php glm_page_menu(); ?>
+                    <?php glm_page_menu(0, '', true, true); ?>
                 </aside>
                 <aside class="right-off-canvas-menu">
                     <div id="gg-open-table-mobile-container" style="padding: 15px;">
index 25268c5..1c9bd77 100755 (executable)
@@ -1,6 +1,6 @@
             <div class="row collapse" id="expanded">
                 <div class="show-for-medium-up medium-3 large-offset-1 large-2 columns">
-                    <?php glm_page_menu(0, 'side-nav'); ?>
+                    <?php glm_page_menu(0, 'side-nav', true); ?>
                     <div class="show-for-medium-up widget">
                         <?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
                         <div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
@@ -8,4 +8,4 @@
                         </div><!-- #primary-sidebar -->
                         <?php endif; ?>
                     </div>
-                </div>
\ No newline at end of file
+                </div>