Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » StaticPublisher & multilanguage

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

Page: 1
Go to End
Author Topic: 586 Views
  • sandro.bilbeisi
    Avatar
    Community Member
    1 Post

    StaticPublisher & multilanguage Link to this post

    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

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: StaticPublisher & multilanguage Link to this post

    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.

    586 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.