Search code examples
drupaldrupal-themespressflow

Drupal 6/Pressflow - assign theme based on domain alias


I know modules like Mobile Tools can do what I want - but they don't work with Pressflow or Varnish.

So, what I'm hoping to do is assign the sitewide theme based on the url used to access it. For instance:

example.com <-- This gets the standard, desktop theme

m.example.com <-- This gets the cool shiny iphone-optimized theme with flashy javascript etc

I dont' want multisite because the content is the same.

I don't want a new entry in domain access because the content is already written and it would (presumably) be a huge hassle to go back and assign it all to the new domain.

There's a Domain Context plugin for context, but it says it loads too late in the flow to be able to change the theme.


Solution

  • We ended up solving it with the recommendation from this thread: http://drupal.org/node/984128#comment-3766156

    if (isset($_SERVER['HTTP_HOST'])) {
       if (stristr($_SERVER['HTTP_HOST'],"stage")) {
                    $GLOBALS['custom_theme'] = 'bar_stage';
        } 
    }