Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

StaticPublisher & multilanguage


Reply


2 Posts   758 Views

Avatar
sandro.bilbeisi

Community Member, 1 Post

6 January 2011 at 1:29am

Edited: 06/01/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

Avatar
ChrisBryer

Community Member, 95 Posts

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.