Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Subsites Module + CustomSiteConfig always loads main SiteConfig when clicking on SiteTree Root


Go to End


6 Posts   2232 Views

Avatar
tmkp

Community Member, 42 Posts

11 February 2011 at 2:07am

Edited: 11/02/2011 2:21am

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.

Avatar
tmkp

Community Member, 42 Posts

23 February 2011 at 6:29am

Edited: 23/02/2011 6:31am

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

Avatar
Sticks

Community Member, 31 Posts

23 September 2011 at 3:05pm

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.

Avatar
DesignCollective

Community Member, 66 Posts

12 January 2012 at 2:16am

Edited: 12/01/2012 2:17am

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.

Avatar
Fraser

Community Member, 48 Posts

6 July 2012 at 2:15pm

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

Avatar
opex

Community Member, 7 Posts

10 July 2012 at 7:33pm

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.