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.

General Questions /

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

Determine Subsite in Page


Reply


2 Posts   385 Views

Avatar
Lazarus404

Community Member, 71 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, 71 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