21290 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 401 Views |
-
StaticPublisher & multilanguage

6 January 2011 at 1:29am Last edited: 6 January 2011 1:31am
StaticPublisher works very well, but the typical implementation only produces the caching of the main SiteTree.
example: http://www.sandrobilbeisi.net/ssx244/
on a website with multiple languages, only the default (English) language is cached, whilst the other languages are not.
I've tried hacking around both the standard implementation (described at : http://doc.silverstripe.org/staticpublisher) and an alternative.
I cannot seem to figure out how to access the translated pages for inclusion in the cache array./**
* Return a list of every page that could be cached
*/
function allPagesToCache() {
$urls = array();
$pages = DataObject::get("Page");foreach($pages as $page) {
$urls[] = $page->Link();
}
return $urls;
}OR
/**
*Return a list of all the pages to cache
*/
function allPagesToCache() {
// Get each page type to define its sub-urls
$urls = array();
// memory intensive depending on number of pages
$pages = DataObject::get("SiteTree");
//print_r($pages);
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;
}cheers,
Sandro Bilbeisi -
Re: StaticPublisher & multilanguage

6 January 2011 at 8:57am
i believe static publishing on non-default locales works if you switch to another locale in the cms and publish there. it doesnt publish all locales at once, but it may be better that way, as it is less resource intensive.
| 401 Views | ||
|
Page:
1
|
Go to Top |


