Page 1 of 1

Switch Style based on hostname?

Posted: Tue Sep 22, 2009 1:26 pm
by SirSydom
Hi folks,

I would like to switch the style/template/theme however you call it based on the current hostname.

I have here a normal s9y installation and the vhost where it is running has some Aliases.
I would like to have theme a displayed when the blog is called by hostname X and theme b when called by hostname Y..

Is that possible?

Regards,

SirSydom

Re: Switch Style based on hostname?

Posted: Tue Sep 22, 2009 2:13 pm
by garvinhicking
Hi!

You would need to create a simple event plugin that listens on the frontend_configure hook and sets $serendipity['template'] depending on $_SERVER['HTTP_HOST'].

I think someone already even requested this, so if you dig a lot you might find more on the forum with this, try it with HTTP_HOST and template and frontend_configure?

HTH,
Garvin

Re: Switch Style based on hostname?

Posted: Tue Sep 22, 2009 4:55 pm
by SirSydom
it doesn't really work..

either

Code: Select all

$serendipity['template'] = $mytemplate;
nor

Code: Select all

$templateInfo = serendipity_fetchTemplateInfo($mytemplate);
$eventData['template'] = $_SESSION['serendipityUseTemplate'];
$eventData['template_engine'] = isset($templateInfo['engine']) ? $templateInfo['engine'] : $serendipity['defaultTemplate'];
$serendipity['smarty_vars']['head_link_stylesheet'] = $serendipity['baseURL'] . 'serendipity.css.php?switch=' . $mytemplate;
does work. Ends up with a totally messed up screen. It works for some templates, but only some.

The templatechoose plugin has the same error, by the way. It uses the second approach.

Re: Switch Style based on hostname?

Posted: Wed Sep 23, 2009 1:33 pm
by garvinhicking
Hi!

What's your full code of your event plugin? Did you properly enable the plugin?

The templatechooser plugin BTW is a good example, it works properly here. Can you show the URL to see what you mean with "messed up"?

Regards
Garvin