Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » 2.4 - DOM in SiteConfig not working for me

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 6381 Views
  • Deklin
    Avatar
    Community Member
    16 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Where should it go? I tried to follow Aram's tutorial as closely as possible but I must have missed something.

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    I'm not familiar with it, but it seems to me those functions need to be defined in the CTF or a subclass thereof. You've defined them in your site config decorator, but they're not doing anything as far as I can see.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Hi Delkin,

    If you look a little closer at the code in the tutorial you'll see that we actually need to create a new class which extends DataObjectManager to put our new function into.

    In this case you need to create a class that extends HadManyComplexTableField which might look like this:

    class SiteConfig_HasManyComplexTableField extends HasManyComplexTableField {
    function setSourceID($val) {
    if (is_numeric($val)) {
    $this->sourceID = $val;
    }
    }
    function sourceID() {
    if (isset($this->sourceID) && $this->sourceID !== null && is_numeric($this->sourceID)) {
    return $this->sourceID;
    }
    return parent::sourceID();
    }
    }

    then in getCMS fields make sure you create a SiteConfig_HasManyComplextTableField instead of just a standard one.

    Out of interest why are you using a CTF over a DOM? I din't realise there was any compelling reason to do so!

    Aram

    www.SSBits.com - SilverStripe Tutorials, Tips and other bits

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Ha... Thanks for the promo, Aram.

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    By the way, would it make sense to roll those functions into the DOM source so you don't have to subclass it? Seems odd to have to create a subclass for something to fundamental.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    Ha... Thanks for the promo, Aram."

    No need for thanks, just saying it how it is

    By the way, would it make sense to roll those functions into the DOM source so you don't have to subclass it? Seems odd to have to create a subclass for something to fundamental.

    Yea that would be awesome, would mean it could be used in SiteConfig without any extra work, except for actually setting the SourceID. In fact would explicitly calling that function in the DOM code adversely effect the DOM when used on a regular page? If not then that would allow it to be used in SiteConfig without any extra code at all....

  • UncleCheese
    Avatar
    4085 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    You want to try it and report your findings? I think what you want is somewhere in the constructor to add $this->setSourceID($this->controller->ID);

    Man, that DOM code is such a mess. I hate going in there. Amazing how an extra year's worth of experience really changes your perception.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: 2.4 - DOM in SiteConfig not working for me Link to this post

    implemented and tested, diff atta...oh can't attach files anymore? Ok you can find it here: http://aabweb.co.uk/assets/Uploads/DataObjectManager.php.diff

    I havnt tested extensively (i.e. with all the different DOM types), though as you'll see from the code I haven't done anything that will effect the sourceID function on normal pages, just added a condition to fetch the sourceID if it can't get it the normal way.

    Let me know if that looks ok

    Thanks UC!

    Aram

    6381 Views
Page: 1 2 3 4 5
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.