Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Advise on correct usage of DataObjectManager

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: 476 Views
  • Stefdv
    Avatar
    Community Member
    110 Posts

    Advise on correct usage of DataObjectManager Link to this post

    UncleCheese,

    I love the DOM, and my question is about cleaning things up.

    I have
    DataObjects ; Serie -> has many seasons -> has many episodes
    Page ; SeriePage

    Now when i add a Serie the popup shows with the button [ Add Season ] , but it shows in the same size as the serie popup. So when i add a Season and close the screen i want to go back to the Serie Popup and not to the CMS.

    If i'm in the Season Popup and add an Episode i get a smaller popup, i want that for my season too
    .
    Now whenever i add a season and close the popup it returns me to the CMS, that's a little bit anoying.

    FYI

    class Serie extends DataObject{

    static $db = array ('SerieName' =>'Varchar(20)',
    ----- and some more --------
    );

    static $has_one = array(
    'SeriePage' =>'SeriePage',
    ' Cover' => 'Image'
    );

    static $has_many = array (' SerieSeasons' => 'SerieSeason');

    public function getCMSFields()
    {
    return new FieldSet(
    new TextField('SerieName'),
    -------And Some more -----,
    new ImageUploadField('Cover'),
    new DataObjectManager(
    $this,
    'SerieSeasons',
    'SerieSeason',
    array('SeasonNmbr' => 'Seizoen')
    ));

    -------------------------------------------------------------------------------------------------

    class SerieSeason extends DataObject {

    static $db = array('SeasonNmbr' =>' Varchar(20)');

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

    static $has_many = array('SerieEpisodes' => 'SerieEpisode');

    public function getCMSFields()
    {
    return new FieldSet
    (
    new TextField('SeasonNmbr', ' Seizoen' ),
    new DataObjectManager(
    $this,
    ' SerieEpisodes',
    'SerieEpisode'
    );
    ----------------------------------------------------------------------------------------------------
    class SerieEpisode extends DataObject {

    static $db = array('EpisodeName' =>' Varchar);

    static $has_one = array('SerieSeason' => 'SerieSeason');
    ----------------------------------------------------------------------------------------------
    class SeriePage extends Page {

    static $has_many = array ('Series' => ' Serie');

    public function getCMSFields()
    {
    $fields = parent::getCMSFields();
    $fields -> addFieldToTab("Root.Content.Series", new DataObjectManager($this));
    return $fields;
    }

    Like i mentioned, everything is working, it's just not that userfriendly this way.

    One minor issue though...After updating to SS 2.4.3 whenever i need to edit a Serie and the popup opens , the fields don't show correctly, i have to go to Next or Previous and then the Fields are allright. ( talking about the ImageUploadField and the Seasons ) this happens with the episode popup also. There i have to choose ' show all' before the fields are refreshed and i can start edit them.
    {posted this issue somewhere else also }

    Thank u already

  • UncleCheese
    Avatar
    4085 Posts

    Re: Advise on correct usage of DataObjectManager Link to this post

    You only get one level of nesting. You can't have three popups. That would be insane!

    Either move your Series object up to the SiteTree and use the Season and Episode objects in a DOM/Nested DOM, or move the whole thing to ModelAdmin, so you can edit dataobjects at the top level.

    See "Nested DOM Test" on the demo site http://dataobjectmanager.carlinowebdesign.com/admin (admin|password)

    and this screencast for more info on nested DOMs: http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/nested-dataobjectmanager-a-dom-in-a-dom/

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

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