Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Subsites module. SiteConfig extension imagedataobject issue

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 315 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    Subsites module. SiteConfig extension imagedataobject issue Link to this post

    I'm having an issue with the subsites module:

    In my site, I am extending SiteConfig to add a number of site-wide options. I am able to set all of these on a persite basis with the exception of the BackgroundImages dataobjectmanager. For some reason, every background I add to each site is added to all the other sites as well. Not just the active one. Is there anything I am doing wrong in my code:

    <?php

    class SiteConfigExtension extends DataObjectDecorator {

       function extraStatics() {
          return array(
             'db' => array(
                'FooterContent' => 'HTMLText',
                'PrimaryColour' => 'Varchar',
                'SecondaryColour' => 'Varchar',
                'Identifier' => 'Varchar'
             ),
             'has_one' => array(
                'Logo' => 'Photo',
                'HeaderPhoto' => 'Photo',
                'DefaultBG' => 'Photo',
                'ToggleTab' => 'Photo'
             ),
             'has_many' => array(
                'BackgroundImages' => 'BackgroundImage'
             )
          );
       }
       static $default_child = "Gallery";
       
       function updateCMSFields(FieldSet &$fields) {
          $fields->addFieldToTab('Root.Footer', new HTMLEditorField('FooterContent', 'Footer Content'));
          $fields->addFieldToTab('Root.DefaultBackground', new ImageUploadField('DefaultBG', 'DefaultBG'));
          $fields->addFieldToTab('Root.Backgrounds', new ImageDataObjectManager($this->owner, 'BackgroundImages', 'BackgroundImage'));
          $fields->addFieldToTab('Root.Styling', new TextField('PrimaryColour', 'Primary Colour'));
          $fields->addFieldToTab('Root.Styling', new TextField('SecondaryColour', 'Secondary Colour'));
          $fields->addFieldToTab('Root.Styling', new ImageField('ToggleTab', 'Toggle Tab'));
          $fields->addFieldToTab('Root.Styling', new TextField('Identifier', 'Identifier'));
          
          $fields->addFieldToTab('Root.Main', new ImageField('Logo', 'Logo'));
          
          $fields->removeByName('Tagline');
          $fields->removeByName('Theme');
       }
       
    }

    Update: I am getting the expected result in the front end of the site (the site they were added from in subsites is displaying the correct background images ), however it is just in the imagedataobjectmanager in the CMS where it is displaying them all together.

    Here is the code for the BackgroundImage class:

    <?php

    class BackgroundImage extends Photo {
       
       static $has_one = array(
          'SiteConfig' => 'SiteConfig'
       );

    }

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