GS Page Cache Plugin

Cache Plugin

What is does

The Page cache plugin caches all you page data into a single XML file called /data/pages/pages.array which is read into an array and is made available to your templates to quickly access page information without having to read in individual files each time information is needed.

The XML file is updated each time a page is edited and saved.

The plugin has been tested with a site with 2500+ pages each one with a menu entry. Page Generation on a site this size was faster by approx 70% as there was only 2 file reads, one for the pages and one for the content. For the above example the menu generation script used the plugin rather than reading in each file.

All data except the "Content" information is added to the file.

Using the plugin

The following functions are available to you:

getPageContent($page) - Echos the content of the Page

getPageField($page,$field) - Echos the Field of the requested Page

returnPageContent($page) - Returns the content of the Page

returnPageField($page,$field) - Returns the Field of the requested Page

getChildren($page) - returns an array of slug names that are children of the given page

Note: $page is the Slug Name

Examples

Menu Generator


function getMenu($currentpage) {</p>
<pre><code>global $PRETTYURLS;
global $digi_pagesArray;
$menu = '';
$startUL=false;
$pagesSorted = subval_sort($digi_pagesArray,'menuOrder'); 
if (count($pagesSorted) != 0) { 
    foreach ($pagesSorted as $page) {
        $sel = ''; $classes = '';
        $url_nav = $page['slug'];            
        if ($page['menuStatus'] == 'Y' && $page['private']!='Y' && $page['parent']=='') { 
            if ("$currentpage" == "$url_nav") { $classes = "current ". $url_nav; } else { $classes = $url_nav; }
            if ($page['menu'] == '') { $page['menu'] = $page['title']; }
            if ($page['title'] == '') { $page['title'] = $page['menu']; }
            $menu .= '<li ><a href="'. find_url($page['slug'],$page['parent']) . '" title="'. $page['title'] .'">'.$page['menu'].'</a>'."n";                
            $submenus=getChildren($url_nav);
            if (count($submenus) != 0) {
               $smenu='';  
               foreach ($submenus as $submenu){
                 if (returnPageField($submenu,'menuStatus')=='Y'){
                  $smenu .=  "<li class='submenu'>".$submenu."</li>";
                 }
               }
               if ($smenu!='') $menu.='<ul>'.$smenu.'</ul>';
            } 
            $menu .='</li>';
        }
    }            
    echo $menu;
}</code></pre>
<p>}

Download

Download the plugin from GetSimple Extend

Requirements

Getsimple 2.x and above

CustomFields Plugin is supported if installed.

Leave a Reply