Jump to:

7940 Posts in 1543 Topics by 946 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: 6486 Views
  • klikhier
    Avatar
    Community Member
    150 Posts

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

    thanks, Uncle Cheese. I tried adding that:

    ...
    $idom->setSourceID($this->owner->ID);
    $idom->setParentClass('SiteConfig');
    $fields->addFieldToTab("Root.Photos", $idom);
    }

    but still I receive

    [User Error] Couldn't run query: SELECT "SlideshowPhoto"."ClassName", "SlideshowPhoto"."Created", "SlideshowPhoto"."LastEdited", "SlideshowPhoto"."Caption", "SlideshowPhoto"."ImageID", "SlideshowPhoto"."CustomSiteConfigID", "SlideshowPhoto"."ID", CASE WHEN "SlideshowPhoto"."ClassName" IS NOT NULL THEN "SlideshowPhoto"."ClassName" ELSE 'SlideshowPhoto' END AS "RecordClassName" FROM "SlideshowPhoto" WHERE ("ParentID" = '1') Unknown column 'ParentID' in 'where clause'

  • silverstriper
    Avatar
    Community Member
    8 Posts

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

    I had this same problem and I solved it by setting a relation back to SiteConfig on the DataObject I was trying to edit in the DOM, so my SiteConfig looks like this:

       function extraStatics() {
          return array(
             'has_many' => array(
                'Notices' => 'Notice'
             )
          );
       }

       public function updateCMSFields(FieldSet &$fields) {

          
          //Notices
          $Manager = new SiteConfig_DataObjectManager(
             $this->owner,
             'Notices',
             'Notice',
             Notice::$summary_fields
          );
          
          $Manager->setParentClass('SiteConfig');
          $Manager->setSourceID($this->owner->ID);
          $fields->addFieldToTab('Root.Notice', $Manager);

          return $fields;   
       }

    and my DataObject has this:

       static $has_one = array(
          'MyCustomSiteConfig' => 'SiteConfig'
       );

    Hope this helps!

  • Zomba
    Avatar
    Community Member
    2 Posts

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

    You are using $Manager = new SiteConfig_DataObjectManager, is there a way to avoid this?
    When i use a $manager, i get a white screen.

    And what do you mean by 'my DataObject'?

    I am trying hard to add a tab called "Banner" where the editor can upload multiple images into the banner which is visible on the entire website. Based on the topic 'adding multiple images to a page type'.

    It works fine in a page type, but because it is different to add it to the SiteConfig, i get stuck.
    What am i doing wrong?

    <?php

    class CustomSiteConfig extends DataObjectDecorator {
       
       function extraStatics() {
          return array(
             'has_many' => array(
                 'GalleryImages' => 'GalleryImage'
             )
          );
       }
       

       public function updateCMSFields(FieldSet &$fields) {      
          
          $manager = new SiteConfig_DataObjectManager(
    $this->owner,
    'GalleryImages',
    'GalleryImage',
           'MyGalleryImage',
    array(
    'GalleryImageTitle' => 'GalleryImageTitle'
    ),
    'getCMSFields_forPopup'
    );

    $manager->setParentClass('SiteConfig');
    $manager->setSourceID($this->owner->ID);
    $fields->addFieldToTab('Root.GalleryImage', $manager);
    return $fields;
       }
    }

  • UncleCheese
    Avatar
    4085 Posts

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

    You don't need to subclass DataObjectManager anymore. Those two sourceID() functions were rolled into the core a few revs ago.

  • mattclegg
    Avatar
    Community Member
    56 Posts

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

    Hey Uncle Cheese,

    I noticed the two sourceID() functions are in rev.418, but

    function setSourceID($val)


    seems to have been removed in rev.419?

    Im guessing its a typo?

  • AdamJ
    Avatar
    Community Member
    145 Posts

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

    So I downloaded DOM and Uploadify from leftandmain.com today, and am trying to get a ImageDataObjectManager working with SiteConfig, but am hitting a similar issue as an earlier poster. Adding images seems to work fine, but if I click on any to edit them, I get the following error:

    [User Error] Couldn't run query: SELECT "BannerImages"."ClassName", "BannerImages"."Created", "BannerImages"."LastEdited", "BannerImages"."Title", "BannerImages"."myImageID", "BannerImages"."ID", CASE WHEN "BannerImages"."ClassName" IS NOT NULL THEN "BannerImages"."ClassName" ELSE 'BannerImages' END AS "RecordClassName" FROM "BannerImages" WHERE ("ParentID" = '1') Unknown column 'ParentID' in 'where clause'

    Here is my code:

    CustomSiteConfig.php

    <?php

    class CustomSiteConfig extends DataObjectDecorator {

    function extraStatics() {
    return array(
    'has_many' => array(
    'Images' => 'BannerImages'
    )
    );
    }
    public function updateCMSFields(FieldSet &$fields) {

    $manager = new ImageDataObjectManager(
    $this->owner,
    'Images',
    'BannerImages',
    'myImage',
    array('Title' => 'Title'),
    'getCMSFields_forPopup'
    );

    $manager->setParentClass("SiteConfig");
    $manager->setPluralTitle('Images');
    $fields->addFieldToTab("Root.Images", $manager);

    }
    }

    BannerImages.php

    <?php
    class BannerImages extends DataObject
    {
       static $db = array (
          'Title' => 'Text'
       );
       
       static $has_one = array (
          'myImage' => 'Image'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Title'),
             new FileIFrameField('myImage')
          );
       }
    }

    Any ideas?

  • UncleCheese
    Avatar
    4085 Posts

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

    Your BannerImage object needs to reciprocate a $has_one to SiteConfig, otherwise, there's no relationship between the two.

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

  • AdamJ
    Avatar
    Community Member
    145 Posts

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

    Yeah, I was just about to post that Silverstriper's fix fixed it for me. Thanks!

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