testing landing page gallery and sidebar menus
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 17 Feb 2016 14:07:53 +0000 (09:07 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 17 Feb 2016 14:07:53 +0000 (09:07 -0500)
landing-page.php
lib/navigation.php

index 5ff3e69..a7538f4 100644 (file)
@@ -20,6 +20,26 @@ Template Name: Landing Page
         </div>
         <div class="row collapse">
             <ul id="quick-sub_pages" class="small-block-grid-1 medium-block-grid-3">
+              <?php global $dyanmic_featured_image; ?>
+               <?php global $post;
+                $image = get_the_post_thumbnail($post->ID);
+                echo $image;
+                $args = array( 'post_parent' =>$post->ID, 'post_type'   => 'page', 'numberposts' => -1, 'post_status' => 'any');
+                $children = get_children($args);
+                foreach($children as $child){ ?>
+                  <?php $images =  $dynamic_featured_image->get_featured_images($child->ID); ?>
+                 <?php foreach($images as $image){
+                    $imageSrc =  $image['full'];
+                }?>
+                  
+                   <?php $imageID = get_post_thumbnail_id($child->ID); 
+                  //  $imageSrc = wp_get_attachment_image_src($imageID, 'full'); ?>
+                    <?php $image = wp_get_attachment_image_src( $child->ID, 'full' ); ?>
+                    
+                     <li class="small-text-center medium-text-left landing-item"><a href="<?php echo get_permalink($child->ID); ?>"><img src="<?php echo $imageSrc; ?>"><h5><?php echo $child->post_title ?></h5></a></li>
+                     
+               <?php } ?>
+<!--
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/Arts-and-Entertainment.jpg"><h5>Arts & Entertainment</h5></a></li>
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/Bicycling.jpg"><h5>Bicycling</h5></a></li>
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/Casinos-and-Nightlife.jpg"><h5>Casinos & Nightlife</h5></a></li>
@@ -30,6 +50,7 @@ Template Name: Landing Page
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/Recreation-and-Parks.jpg"><h5>Recreation & Parks</h5></a></li>
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/Tours.jpg"><h5>Tours</h5></a></li>
                 <li class="small-text-center medium-text-left landing-item"><a><img src="<?php bloginfo('template_url');?>/assets/landing-img/269-Cool-Things-To-Do.jpg"><h5>269&trade; Cool Things To Do</h5></a></li>
+-->
             </ul>
         </div>
         <div class="row collapse">
index feea943..c6f373d 100644 (file)
@@ -163,20 +163,96 @@ function glm_get_menu_options()
     }
     return $menu_options;
 }
-
-function glm_side_menu() {
-    global $post;
-    $parents = get_post_ancestors($post->ID);
-    $id = ($parents) ? $parents[count($parents)-1]: $post->ID;
-    $parent = get_page( $id );
-    if ($id == 0) {
-        $ID = $post->ID;
+//function glm_side_menu() {
+//    global $post;
+//    $parents = get_post_ancestors($post->ID);
+//    $id = ($parents) ? $parents[count($parents)-1]: $post->ID;
+//    $parent = get_page( $id );
+//    if ($id == 0) {
+//        $ID = $post->ID;
+//    } else {
+//        $ID = $parent->ID;
+//    }
+//    echo '<h2>'.get_the_title($ID).'</h2>';
+//    echo '<ul class="sidebar"><!-- begin -->'."\n";
+//    echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
+//    echo '</ul><!-- end -->'."\n";
+//}
+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']);
+        }
+        $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;
+            $allMenu[$menu_item->ID] = $menu_item;
+            if ($menu_item->object_id == $post->ID) {
+                $pageMenuId[] = $menu_item;
+            }
+        }
+        if (count($pageMenuId) > 1) {
+            $thisPageMenuId = (isset($pageMenuId[1])) ? $pageMenuId[1]->ID : 0;
+            $thisPageMenuParent = (isset($pageMenuId[1])) ? $pageMenuId[1]->menu_item_parent : 0;
+            foreach ($pageMenuId as $men) {
+                if (isset($sideMenu[$men->ID]) && !empty($sideMenu[$men->ID])) {
+                    $thisPageMenuId     = $men->ID;
+                    $thisPageMenuParent = $men->menu_item_parent;
+                }
+            }
+        } else {
+            $thisPageMenuId = (isset($pageMenuId[0])) ? $pageMenuId[0]->ID : 0;
+            $thisPageMenuParent = (isset($pageMenuId[0])) ? $pageMenuId[0]->menu_item_parent : 0;
+        }
+        // does the current page (in the menu) have sub menu items?
+        if (isset($sideMenu[$thisPageMenuId]) && !empty($sideMenu[$thisPageMenuId])) {
+            $pageHead  = $allMenu[$thisPageMenuId];
+            // get the subs for $thisPageMenuId
+            $subs = $sideMenu[$thisPageMenuId];
+            // 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];
+//            }
+        } else if ($thisPageMenuParent)  {
+            $pageHead  = $allMenu[$thisPageMenuParent];
+            // get the subs for $thisPageMenuParent
+            $subs = $sideMenu[$thisPageMenuParent];
+        } else {
+            $pageHead  = $allMenu[0];
+            // get Main level
+            $subs = $sideMenu[0];
+        }
+    
+    if ($mobile) {
+        echo '<ul>';
+        echo '<li><a href="'.get_bloginfo('url').'">Home</a></li>';
+        echo '<li><a href="'.$pageHead->url.'"';
+        if ($pageHead->target) {
+            echo ' target="'.$pageHead->target.'"';
+        }
+        echo '>'.$pageHead->title.'</a><ul>';
     } else {
-        $ID = $parent->ID;
+        echo '<h1><a href="'.$pageHead->url.'"';
+        if ($pageHead->target) {
+            echo ' target="'.$pageHead->target.'"';
+        }
+        echo '>'.$pageHead->title.'</a></h1>';
+        echo '<ul>';
     }
-    echo '<h2>'.get_the_title($ID).'</h2>';
-    echo '<ul class="sidebar"><!-- begin -->'."\n";
-    echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
-    echo '</ul><!-- end -->'."\n";
+    foreach ($subs as $menu_item) {
+        echo '<li><a href="'.$menu_item->url.'"';
+        if ($menu_item->target) {
+            echo ' target="'.$menu_item->target.'"';
+        }
+        echo '>'.$menu_item->title.'</a></li>';
+    }
+    if ($mobile) {
+        echo '</ul>';
+    }
+    echo '</ul>';
 }