Same blog with 2 different domains each with its own header and footer

Permalink
Hi,

I would like to have 2 domains for my website and depending which domain a user arrives on they will have a different header.

The content is exactly the same!

I was thinking of using the Domain Mapper add-on but I want the same content just a differnet theme not a different section of the same website.

Any suggestions?

Cheers

damshaw
 
mkly replied on at Permalink Reply
mkly
There is a theme switcher addon. This could be quickly modified to allow to switch via domain.
damshaw replied on at Permalink Reply
damshaw
Cool thanks for that!

My PHP is pretty average... Do you know ifI would modify something in controller.php?

Cheers
mkly replied on at Permalink Best Answer Reply
mkly
It looks like the controller calls
Events::extend('on_start', 'ThemeSwitcher', 'checkForTheme', './packages/theme_switcher/models/theme_switcher.php');


So the dirtiest way would probably just go to models/theme_switcher and change

if ($_GET['t']) {
            $theme = PageTheme::getByHandle($_GET['t']);
            $view->setTheme($theme);
         }
         //if the get is not set, then set it from the cookie
         else if ($_COOKIE['ccmUserTheme']) {
            $theme = PageTheme::getByHandle($_COOKIE['ccmUserTheme']);
            $view->setTheme($theme);
         }


to

$domain = $_SERVER['HTTP_HOST'];
if (strpos($domain, 'mydomain1.com') !== false) {
  $view->setTheme('handle_of_theme1');
} elseif (strpos($domain, 'mydomain2.com') !== false) {
  $view->setTheme('handle_of_theme2');
}


*I think. Test it and let me know.
damshaw replied on at Permalink Reply
damshaw
Thats great!
I should have extra domain by afternoon and I will let you know how it goes!

Thanks for the quick posts!

awesome!

Damshaw
damshaw replied on at Permalink Reply
damshaw
Hey, Yeah that works almost perfectly!
Except it also applies the theme to the dashboard. Do you know of a way to make an exception for website/index.php/dashboard/

thanks for the help!

damshaw
mkly replied on at Permalink Reply
mkly
Did you happen to remove the
if(!$page->isAdminArea() && !$page->isSystemPage()) {

part?
The whole theme_switcher.php should look like

<?php  
class ThemeSwitcher {
  public function checkForTheme($view) {
    //get the current page
    $page = Page::getCurrentPage();
    //get the path of the page,
    $cpath = $page->getCollectionPath();
    //Make sure its not a system page or the login screen or some other pages, we don't wanna theme the Dashboard
    if (!$page->isAdminArea() && !$page->isSystemPage()) {
      $domain = $_SERVER['HTTP_HOST'];
      if (strpos($domain, 'mydomain1.com') !== false) {
        $view->setTheme('handle_of_theme1');
      } elseif (strpos($domain, 'mydomain2.com') !== false) {
        $view->setTheme('handle_of_theme2');
      }
damshaw replied on at Permalink Reply
damshaw
Ha! Thanks I should have at least noticed that! You are a legend!!!!!!