Hello,
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? :)