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

Change Default Subsite


Go to End


3 Posts   1489 Views

Avatar
dompie

Community Member, 88 Posts

11 January 2011 at 5:00am

Hello,

although Subsites is not coded to work with SS 2.4, it works most the time. Anyway, maybe someone can give me some hints how to fix the following 2 issues, to make it work better with SS 2.4.

I have the following Subsites created:
SubSite A
SubSite B

1) I created a user and put him into a "Content Editors" Group and allowed access to all Subsites (and languages). When the user logs in, always 'SubSite A' is active by default. How can I change this and make 'Main Site' the default after login? I tried to hard code, and to modify SubsiteList / currentSubsiteID, but without success :(

2) Furthermore I'm using Translatable together with Subsites. Every time I change the language on 'Main Site' or 'SubSite B', 'SubSite A' becomes active. Anyone got an idea how to fix this? (workaround would be great too).

Avatar
DesignCollective

Community Member, 66 Posts

4 November 2011 at 3:47pm

Edited: 04/11/2011 3:48pm

Anyone had any progress on this?

This has been an issue for me for editing child pages under RemodelAdmin. I just realized thanks to your post that the issue is that not the Main site but a subsite is forced for non-admins...

Avatar
DesignCollective

Community Member, 66 Posts

19 November 2011 at 6:09am

Edited: 19/11/2011 6:09am

I just did this - it may help. Under Subsite.php, there is a changeSubsite() method.

I set up my various ModelAdmin classes to work with numeric PageIDs and added a $subsiteID parameter.

<?php
class BlogAdmin extends RemodelAdmin {

	static $managed_models = array (
		'ArticlePage'
	);
	static $url_segment = "blog";
	static $menu_title = 'Blog';
	public $showImportForm = false;
	static $parent = 100;
	static $parent_page_type = "ArticleHolder";
	
	static $subsiteID=1;
}

Then I just added this into the init funciton of RemodelAdmin.php:


public function init() {
	    parent::init();
...
	    if(($subsiteID = $this->stat('subsiteID'))>=0 ) {
	    	Subsite::changeSubsite($subsiteID);
	    }
}

It may not be orthodox, but it sure works, esp since I have article sections in several subsites managed with RemodelAdmin by different users.

I am guessing you could do the same and perhaps check what subsite needs to be set based on the user's group. Hope this helps anyone!