Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjectManager and Translations

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1105 Views
  • Dave L
    Avatar
    Community Member
    56 Posts

    DataObjectManager and Translations Link to this post

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

  • Dave L
    Avatar
    Community Member
    56 Posts

    Re: DataObjectManager and Translations Link to this post

    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.

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