Jump to:

23553 Posts in 19380 Topics by 2892 members

General Questions

SilverStripe Forums » General Questions » problem about getting dataobjects and pages from another translatable local

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: 866 Views
  • ayyurek
    Community Member
    41 Posts

    problem about getting dataobjects and pages from another translatable local Link to this post


    I have a problem with translatable extension using getTranslation method.

    I built a multilingual site with 5 languages, with en_US as default locale. Many content like Image Galleries, Sliders and Events will be common in every language. I have some basic functions in Page.php for showing last 5 events and etc on the sidebar of the pages.

    function TopAttractions($num=3) {
       return DataObject::get("AttractionPage", "FeaturedAtts = 1", "ID DESC", "", $num);

    function UpcomingEvents($num=1) {
       return DataObject::get("Event", "", "Date DESC", "", $num);

    How can I create a function to always return the dataobjects from the original locale?

    function translatedGalleryImages() {
    $Data = $this -> GalleryImages();
    // Get Dataobjects from Original-Languague-Page
    if ($this->Locale != Translatable::default_locale()) {
    $Data = $this->getTranslation(Translatable::default_locale()) -> GalleryImages();
    return $Data;

    I used the code below for many times, but I used always for getting the child dataobejects of a page. I think it doesn't work with Pages.
    Is there anybody who can help?

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.