Hi
I have turned on the static publisher by adding this code to my _config.php
Object::add_extension("SiteTree", "FilesystemPublisher('cache/', 'html')");
And also in my .htaccess
Added the following
### Replaced with new directives to support static publisher
# http://doc.silverstripe.com/doku.php?id=staticpublisher
### SILVERSTRIPE START ###
RewriteEngine On
## CONFIG FOR TEST/LIVE ENVIRONMENTS
# Cached content - live webserver
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} /(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /cache/%1.html [L]
# Cached content - homepage
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /cache/index.html [L]
## DYNAMIC CONFIG
# Dynamic content
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
### SILVERSTRIPE END ###
And in my Page.php
Added the following functions
function allPagesToCache() {
// Get each page type to define its sub-urls
$urls = array();
// memory intensive depending on number of pages
$pages = DataObject::get("SiteTree");
foreach($pages as $page) {
$urls = array_merge($urls, (array)$page->subPagesToCache());
}
// add any custom URLs which are not SiteTree instances
$urls[] = "sitemap.xml";
return $urls;
}
/**
* Get a list of URLs to cache related to this page
*/
function subPagesToCache() {
$urls = array();
// add current page
$urls[] = $this->Link();
// cache the RSS feed if comments are enabled
if ($this->ProvideComments) {
$urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID;
}
return $urls;
}
function pagesAffectedByChanges() {
return $this->allPagesToCache(); // added line
// $urls = $this->subPagesToCache();
// if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
// return $urls;
}
However, i realized that after the cache is turned on, when i access the page, the submenu links are not working correctly
for the blankcandy and evergreenz themes.
For eg, if i try to select any items on the submenu, the highlighted link does not displayed correctly when i switch to another submenu item.
This problem does not occurs if the cache is turn off.
Anyone got any idea on how to solve that?
Greatly appreciated !
Thanks