put the main nav into cache
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Feb 2010 16:48:35 +0000 (16:48 +0000)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Feb 2010 16:48:35 +0000 (16:48 +0000)
admin/Toolbox/list_bus_category.phtml
admin/Toolbox/update_bus_category.phtml
classes/class_template.inc

index e0f927e..49a8e18 100755 (executable)
@@ -28,6 +28,7 @@ if(isset($active)) {
        $DB->db_exec($query);
        GLM_TOOLBOX::create_sitemap();
     $toolbox->cache->clean('Nav');
+    $toolbox->cache->clean('MainNav');
 }
 $toolbox_nav["Edit Positions"] = "list_bus_category.phtml?show_pos=1";
 $toolbox_nav["Expand All"] = "list_bus_category.phtml?expand_all=1";
index be87eb5..89df1c8 100755 (executable)
@@ -308,6 +308,7 @@ if ($REQUEST_METHOD == "POST" || $Command == "Move") {
 }
 // remove the cache for this paragraphs
 // cach_Toolbox_page-$ID
+$toolbox->cache->clean('MainNav');
 $toolbox->cache->remove('page-' . $id, 'Toolbox');
 $toolbox->cache->remove('paragraphs-' . $id, 'Toolbox');
 //GLM_TOOLBOX::create_sitemap();
index 48a249a..ee71a56 100644 (file)
@@ -997,27 +997,32 @@ class GLM_TEMPLATE
        }
 
        //      }}}
-       //      {{{ get_main_nav()
+       //      {{{ get_main_nav(
 
        function get_main_nav($topParent)
        {
-               $query = "select id,category
-                       from bus_category
-                       where parent = 0
-                       and active = 't'
-                       order by pos";
-               if ($data = $this->DB->pgsql_select( $query ) ){
-                       $out = '<ul>';
-                       foreach( $data as $row ){
-                $out .= '<li><a ';
-                if ($row['id'] == $topParent) {
-                    $out .= ' class="active"';
+        if ($navContent = $this->cache->get($topParent, 'MainNav')) {
+            return $navContent;
+        } else {
+            $query = "select id,category
+                from bus_category
+                where parent = 0
+                and active = 't'
+                order by pos";
+            if ($data = $this->DB->pgsql_select( $query ) ){
+                $out = '<ul>';
+                foreach( $data as $row ){
+                    $out .= '<li><a ';
+                    if ($row['id'] == $topParent) {
+                        $out .= ' class="active"';
+                    }
+                    $out .= 'href="'.$this->get_seo_url( $row['id'] ).'">'.$row['category'].'</a></li>';
                 }
-                $out .= 'href="'.$this->get_seo_url( $row['id'] ).'">'.$row['category'].'</a></li>';
-                       }
-                       $out .= '</ul>';
-               }
-               return $out;
+                $out .= '</ul>';
+            }
+            $this->cache->save($out, $topParent, 'MainNav');
+            return $out;
+        }
        }
 
        //      }}}