Add all sub levels for main navigation
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 31 Jul 2014 17:52:02 +0000 (13:52 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 31 Jul 2014 17:52:02 +0000 (13:52 -0400)
Adding all the sub levels for main nav.
First level used is controlled by the define for MAIN_LEVEL_NAV_ARRAY
in setup.phtml.

Toolkit/Page.php
setup.phtml
templates/template.html

index 20f3b32..84e0ea7 100755 (executable)
@@ -513,8 +513,12 @@ class Toolkit_Page
             $this->pageId = $this->_catid;
         }
         $this->_navigationFactory->setGateway($this->_pageGateway);
+        // mainNav is the mobile navigation output
         $this->mainNav = $this->_getMainNav($this->_catid);
+        // sideNav output
         $this->sideNav = $this->_getSideNav($this->_catid);
+        // main Navigation output
+        $this->mainNavigationUl = $this->_getMainNavigation();
 
         $this->newsletterAction = Toolkit_Template_Page::getSeoUrl(
             $this->_pageGateway, 10
@@ -620,7 +624,7 @@ class Toolkit_Page
      *
      * @param type $catid page catid
      *
-     * @return type
+     * @return string
      */
     private function _getMainNav($catid)
     {
@@ -632,6 +636,31 @@ class Toolkit_Page
         return ($html) ? $html : '';
     }
 
+    /**
+     * Returns the main level navigation and all the subs
+     * Locked down to a few top levels
+     *
+     * @return string
+     */
+    private function _getMainNavigation()
+    {
+        if (defined('MAIN_LEVEL_NAV_ARRAY') && MAIN_LEVEL_NAV_ARRAY) {
+            $mainNavArray = unserialize(MAIN_LEVEL_NAV_ARRAY);
+        }
+        $sideNav = new Toolkit_Template_Navigation_AllInOneSideNav(
+            $this->_pageGateway
+        );
+        $nav  = $sideNav->getNavigation();
+        $newNav = array();
+        foreach ($nav as $key => $item) {
+            if (in_array($item['id'], $mainNavArray)) {
+                $newNav[] = $item;
+            }
+        }
+        $html = $this->_arrayToListHTML($newNav, 0, 'clearfix');
+        return ($html) ? $html : '';
+    }
+
     /**
      * _arrayToListHTML
      *
index 927ef48..3cd8f9c 100644 (file)
@@ -54,6 +54,8 @@ if (!isset($DEBUG)) {
 }
 $securePagesArray = array();
 define('SECURE_PAGES', serialize($securePagesArray));
+$mainNavigationUl = array(2,7,10,11);
+define('MAIN_LEVEL_NAV_ARRAY', serialize($mainNavigationUl));
 $nonMobilePagesArray = array();
 define('NON_MOBILE_PAGES', serialize($nonMobilePagesArray));
 /**
index 9ca50ff..6cd5563 100755 (executable)
                                 </form>
                             </div>
                             <nav class="clearfix  hide-for-small-only">
-                                <ul class="clearfix sf-menu">
-                                    <li>
-                                        <a href="{baseURLDefined:h}departments-2/">Departments</a>
-                                    </li>
-                                    <li>
-                                        <a href="{baseURLDefined:h}documents-7/">Documents</a>
-                                    </li>
-                                    <li>
-                                        <a href="{baseURLDefined:h}calendars-10/">Calendars</a>
-                                    </li>
-                                    <li>
-                                        <a href="{baseURLDefined:h}contact-11/">Contact</a>
-                                    </li>
-                                </ul>
+                                {mainNavigationUl:h}
                             </nav>
                         </div>
                     </div>
                                 <a href="{getToolboxUrl(#21#):h}">Recreation Department</a>
                                 <i>(906) 298-0333</i>
                                 <a href="mailto:recdept@cityofmi.org">recdept@cityofmi.org</a>
-                            </div>                           
+                            </div>
                         </div>
                         <div class="small-6 medium-3 large-3 columns data-equalizer-watch">
                             <div>