Jump to:

3375 Posts in 999 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » DataObject::get with Translatable ON - SiteTree/Page difference.

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

Page: 1
Go to End
Author Topic: 539 Views
  • pali
    Avatar
    Community Member
    33 Posts

    DataObject::get with Translatable ON - SiteTree/Page difference. Link to this post

    Hello,

    im using this really simple setup, but im surprised with odd behaviour.

    This code will return only localized pages:

    return DataObject::get("SiteTree");

    this is returning all pages - doesn't care about locale:

    return DataObject::get("Page");

    SS version:
    SS 2.4.6

    mysite/_config.php:

    Translatable::set_default_locale('en_US');
    Object::add_extension('SiteTree','Translatable');
    Object::add_extension('SiteConfig','Translatable');
    Translatable::set_allowed_locales(array('en_US','ru_RU'));

    mysite/code/Page.php >> Page_Controller:

    ...

    public function init() {
          
          parent::init();
          
          if($this->dataRecord->hasExtension('Translatable')) {
             i18n::set_locale($this->dataRecord->Locale);
             setlocale(LC_TIME, $this->dataRecord->Locale . ".utf8");
          }   
    ...
    }

    ...

    Is this standard behaviour?

    Regards

    Pali

    539 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.