Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1242 Views
  • tmkp
    Avatar
    Community Member
    42 Posts

    Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    Hi,

    I'm having a couple of issues with the Subsites Module, and i feel like they might be related somehow.

    Running 2.4.5 and the latest subsites trunk (r116127) I've set up a main site and one subsite.

    Following this tutorial I created a CustomSiteConfig Decorator to store a HTML Footer and registered the Decorator in my mysite/_config.php

    <?php

    class CustomSiteConfig extends DataObjectDecorator {

       function extraStatics() {
          return array(
             'db' => array(
                'Footer' => 'HTMLText'
             )
          );
       }

       public function updateCMSFields(FieldSet &$fields) {

          // add footer field
          $fields->addFieldToTab("Root.Main", new HtmlEditorField("Footer", "Footer", 10));

       }

    }

    And in mysite/_config.php

    // add CustomSiteConfig
    DataObject::add_extension('SiteConfig', 'CustomSiteConfig');

    Then, following the instructions here http://open.silverstripe.org/ticket/5997 I managed to get Subsites to save and load the correct SiteConfigs when using the Dropdown menu in the CMS Header area.

    However, if I click on the root icon (the one with the little globe) in my subsite's SiteTree, the main Siteconfig is being loaded, with the SiteTree still showing my Subsite's page structure. If I edit values and hit save, the main Siteconfig gets overwritten, but I'm still seeing my Subsite's SiteTree.

    I couldn't find any related tickets in the bugtracker, is this a known issue or is anybody else experiencing the same problem?

    I think Subsites in connection with SiteConfig would be a fantastic extension to Silverstripe and i'd love to use it in an upcoming project, so I'm tipping my hat to the developers of these little gems.

    Any help would be greatly appreciated. Thanks in advance,

    Andi

    ------------------- EDIT: --------------------

    The same issue occurs when I add a DataObjectManager to my CustomSiteConfig Decorator

       function extraStatics() {
          return array(

    ...

             'has_many' => array(
                'SlideshowImages' => 'SlideshowImage'
             )
          );
       }

       public function updateCMSFields(FieldSet &$fields) {

    ...

          // add slideshow manager
          $manager = new DataObjectManager(
             $this->owner,
             'SlideshowImages',
             'SlideshowImage',
             array('Title' => 'Title'),
             'getCMSFields_forPopup'
          );
          
          $manager->setSourceID($this->owner->ID);
          $fields->addFieldToTab("Root.Images", $manager);

       }

    Everything loads up correctly when navigating to SiteConfig via the Subsites Dropdown, but if I add new images to my subsite and close the DOM Popup, the main SiteConfig gets loaded, with the added DataObjects linking up to the main site's SiteConfig.

  • tmkp
    Avatar
    Community Member
    42 Posts

    Re: Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    This is a friendly bump.

    Just updated my testbed to the latest subsites trunk (r116457) but both issues persist.

    I'm just about to start a new project for a client and i would love to use Silverstripe/Subsites. I guess i could figure out a workaround for the IDOM issue, but the problem with clicking the SiteTree Icon resulting in loading of the wrong Siteconfig makes the system feel somewhat quirky and will require me to look around for an alternative.

    Can anybody reproduce this behaviour? Pointers, hacks, workarounds, everything would be greatly appreciated!

    Thanks again!

    Andi

  • Sticks
    Avatar
    Community Member
    29 Posts

    Re: Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    I'm having this exact same issue. I have multiple subsites with multiple custom DataObjectManager fields added to a SiteConfig decorator and they all seem to show the same data objects. I can move all of these custom fields to the HomePage.php and that would surely work but I'd rather there was a solution to this problem.

  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Re: Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    Hi there, same problem on a large website! I made a working solution by only opening siteconfig fields if Subsite::currentSubsiteId was greater than 0, otherwise CustomSiteConfig returns null for cms fields.

    Doesn't solve the JavaScript issue, but at least if the main site's siteconfig is loaded (be it on the right site tree or not), it can't be overwritten. In my case, the main site's config stays constant, while the subsites are edited by many, often, so it works.

  • Fraser
    Avatar
    Community Member
    46 Posts

    Re: Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    Did anyone find a solution to this? I'm having the same problem as Sticks

  • opex
    Avatar
    Community Member
    7 Posts

    Re: Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root Link to this post

    This fix isn't thoroughly tested!

    By commenting out line 253 and 263 in SiteTreeSubsites.php where the session SubsiteID is set to null, all issuses I'm having with subsites seem to be resolved. I'm sure the developer thought of something when implementing it, but I can't find the use case where it's applicable.

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