1

I have this in settings.php:

$THEME_URLS = array(
  array('/optoelectronics','sky'),
);
foreach ($THEME_URLS as $info) {
  if (strpos($_SERVER['REQUEST_URI'], $info[0]) === 0) {
    $conf['theme_default'] = $info[1];
  }
}

I have two domains each based on a different theme. The issue is that I'm trying to use part of the old theme for just these two sections but the other theme is entirely based on SKY and if I make any modifications to the css or create a page-optoelectronics.tpl.php, then both sites receive the modifications, which I don't want.

So I duped the theme "sky" and changed all appropriate names and such to 'optotemp' but as I mention above, Drupal still disregards the "http://www.site.com" part and switches to 'optotemp' when it sees /optoelectronics.

So I found $base_url which returns the full path, including the host.

I'm a little rusty with the combination of an if/else command and including the array above in one fell swoop.

I want to say: If the absolute path is http://www.sitea.com/optoelectronics use theme optotemp. Otherwise, use the default theme. This command would then mean by default that http://www.siteB.com/optoelectronics would still use the theme assigned to that domain via the domain access module, which is Sky.

In other words, www.sitea.com has a new entire theme, but two sections of www.sitea.com will need to use optotemp but www.siteb.com uses sky.

I need help on knowing the syntax to get this right.

var $usOrEuro = $base_url;
if ($usOrEuro == 'http://www.sitea.com/optoelectronics'){
  $appliedTheme = 'optotemp';
}

$THEME_URLS = array(
  array($usOrEuro, $appliedTheme),
);
foreach ($THEME_URLS as $info) {
  if (strpos($_SERVER['REQUEST_URI'], $info[0]) === 0) {
    $conf['theme_default'] = $info[1];
  }
}
0

This should do it:

$hosts = array('sitea.com', 'www.sitea.com');
if (in_array($_SERVER['HTTP_HOST'], $hosts) && $_SERVER['REQUEST_URI'] == '/optoelectronics') {
  $conf['theme_default'] = 'optotemp';
}
|improve this answer|||||
  • well, no go. I put this in the settings.php file: $hosts = array('sitea.com', 'www.sitea.com'); if (in_array($_SERVER['HTTP_HOST'], $hosts) && $_SERVER['REQUEST_URI'] == '/optoelectronics') { $conf['theme_default'] = 'optotemp'; } substituting the real domain of course. But, I stuck a little span at the bottom and the template within the optotemp style is not being called at the url. – kelly johnson May 20 '13 at 20:29
  • Hmm, not sure why - I tested the same thing locally (with a different domain obviously) and it worked just fine – Clive May 20 '13 at 20:36
  • I think it's the darn Domain Access module. It seems powerful until you hit the specific user case where one of two sites, each with different themes, has to share a theme from the other. The IP doesn't have anything to do with this, does it? Because of the Domain Module, the other domain (siteb) is pointed to the main site(sitea), so within Drupal the IP is the same for both sites. – kelly johnson May 20 '13 at 20:42
  • The IP wouldn't make any difference, no...have you tried ThemeKey? – Clive May 20 '13 at 20:46
  • Yes, but as I'm in 6.28 there seems to be conflicts as Domain Access is overriding anything there. It seems like there should be an easy way using something in Settings.php because that's the last stop before index.php, right? Anyway, thanks for help. – kelly johnson May 20 '13 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.