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.

General Questions /

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

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

Determine Subsite in Page


Go to End


2 Posts   682 Views

Avatar
Lazarus404

Community Member, 72 Posts

25 April 2012 at 7:15pm

Hey guys,

So, I'm using a controller to provide services to some Ajax based pages. I'm also using subsites. What I'd like to do is to allow each site to know what subsite its in, so it can make some adjustments.

So, question; is there a way, within a controller, to determine what subsite is currently being served?

Thanks in advance,
Lee

Avatar
Lazarus404

Community Member, 72 Posts

26 April 2012 at 9:53am

Figured it out. For those of you who have the same requirement, just do:-

Subsite::currentSubsite();

Then, you can, perhaps, differentiate using

$site = Subsite::currentSubsite();
$title = $site->Title;

Lee