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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Themes /

Discuss SilverStripe Themes.

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

RightBar sontrolled by subdomains


Go to End


2 Posts   1021 Views

Avatar
t00thy

Community Member, 31 Posts

14 June 2011 at 2:41am

Hi
i have this problem. I have website zetorbar.cz with two subdomains: brandys.zetorbar.cz and liberec.zetorbar.cz.
I have different layout.css files for the subdomains and main domain. What I need is put different content in RightBar directly to subdomain.
I have this code in HomePage.php:

function PostersRight($num=5) {
	
		if ($_SERVER['HTTP_HOST']=="www.zetorbar.cz" || $_SERVER['HTTP_HOST']=="www.zetorbar.cz" )
			{
			$news = DataObject::get_one("ZetorPostersHolder");
			}
		elseif ($_SERVER['HTTP_HOST']=="liberec.zetorbar.cz" || $_SERVER['HTTP_HOST']=="liberec.zetorbar.cz" )
			{
			$news = DataObject::get_one("LiberecPostersHolder");
			}
		elseif ($_SERVER['HTTP_HOST']=="brandys.zetorbar.cz" || $_SERVER['HTTP_HOST']=="brandys.zetorbar.cz" )
			{
			$news = DataObject::get_one("BrandysPostersHolder");
			}
		else
			{
			$news = DataObject::get_one("ZetorPostersHolder");
			}

		return ($news) ? DataObject::get("Plakat", "ParentID = $news->ID", "", "", "") : false;
	}

It says, that when I open:
liberec.zetorbar.cz, i get LiberecPostersHolder on the RightBar. And its OK

but when I open:
brandys.zetorbar.cz i get ZetorPostersHolder, or
www.zetorbar.cz i get BrandysPostersHolder

In the CMS I have three HomePages. One for www.zetorbar.cz and zetorbar.cz, second for brandys.zetorbar.cz and third for liberec.zetorbar.cz

I use SS 2.4.5

Avatar
zenmonkey

Community Member, 545 Posts

21 July 2011 at 6:41am

Are you using the subsites module? http://silverstripe.org/subsites-module/

It actually provides methods for detecting which sub-site you're on