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.

Themes

Discuss SilverStripe Themes.

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

RightBar sontrolled by subdomains


Reply

2 Posts   666 Views

Avatar
t00thy

14 June 2011 at 2:41am Community Member, 31 Posts

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

21 July 2011 at 6:41am Community Member, 528 Posts

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

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