Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjectManager and Translations


Reply

2 Posts   1190 Views

Avatar
Dave L

23 February 2010 at 3:17pm Community Member, 56 Posts

Hi,

I'm having an issue with DataObjects attaching to wrong translation pages.

<?php

class FAQPage extends Page {

static $has_many = array (
'FAQs' => 'FAQ'
);

public function getCMSFields() {
$fields = parent::getCMSFields();
$dom = new DataObjectManager(
$this,
'FAQs',
'FAQ',
array('Question'=>'Question'),
'getCMSFields_forPopup',
"FAQPageID = $this->ID"

);
$fields->addFieldToTab("Root.Content.FAQ", $dom);
return $fields;
}

}

?>

<?php

class FAQ extends DataObject {

static $db = array (
'Question' => 'Text',
'Answer' => 'Text'
);

static $has_one = array (
'FAQPage' => 'FAQPage'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Question'),
new TextField('Answer')
);
}

}

?>

When I go to the English version of FAQPage I can add FAQs fine. Then I select translations and choose the translated page (Mandarin in this case) and the FAQ DOM shows empty, as you'd expect. I add a new FAQ but then when I close lightbox the page refreshes showing all FAQ - the one I added plus the English ones. If I refresh the FAQ including the one I added are gone. Then If I switch back to English through the translations tab all FAQ including the Chinese one added show there. Then all FAQs show in the English page since the FAQPageID is the same for all.

Am I doing something wrong?

Also,

If I am viewing the English sitetree, then use the language dropdown > switch to Mandarin > select FAQPage > select FAQ tab > select "add a new FAQ" I get the error "I can't handle sub-URLs of a CMSMain object." in the lightbox popup.

This is revision 216. Please note there is a change between r216 and r217 that renders lightbox fullscreen (full window) on my browser (Mac FireFox 3.5.4).

Avatar
Dave L

24 February 2010 at 4:11pm Community Member, 56 Posts

Looks like the issue is locale not being propagated. See http://silverstripe.org/dataobjectmanager-module-forum/show/262423

So it's attaching to the master page, not the translated one.