Hi,
im trying to manage DOM from different site - as an example - i have default page with photos and this page is translated to different language. I would like to show Photos from default lang on translated Page (in backend, frontend is OK).
Im trying this w/o success:
PhotosPage.php
class PhotosPage extends Page {
public static $has_many = array(
'Photos' => 'Photo'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
if ($this->Locale != Translatable::default_locale()) {
$tPage = $this->getTranslation(Translatable::default_locale());
$filter = 'PhotosPageID = ' . $tPage->ID;
$manager = new DataObjectManager(
$tPage,
'Photos',
'Photo',
array(
'Name' => 'Názov',
), // Headings
'getCMSFields_forPopup',
$filter
);
$manager->setPermissions(
array(
"show"
)
);
} else {
$manager = new ImageDataObjectManager(
$this,
'Photos',
'Photo',
'PhotoImage',
array(
'Name' => 'Názov',
), // Headings
'getCMSFields_forPopup'
);
$manager->setUploadFolder('Photos/'.$this->ID);
}
$fields->addFieldToTab("Root.Content.Photos", $manager);
return $fields;
}
...
Photos.php:
class Photo extends DataObject
{
static $db = array (
'Name' => 'Text'
);
static $has_one = array (
'PhotoImage' => 'Image',
'PhotosPage' => 'PhotosPage'
);
public function getCMSFields_forPopup()
{
$fields = new FieldSet(
new TextField('Name')
);
$this->extend('updateCMSFields_forPopup', $fields);
return $fields;
}
public function onBeforeWrite() {
if (empty($this->Name)) {
$this->Name = $this->PhotosPage()->Title;
}
parent::onBeforeWrite();
}
Regards
Pali