Switch Style based on hostname?

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
SirSydom
Regular
Posts: 12
Joined: Thu Nov 23, 2006 12:32 pm

Switch Style based on hostname?

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Switch Style based on hostname?

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
SirSydom
Regular
Posts: 12
Joined: Thu Nov 23, 2006 12:32 pm

Re: Switch Style based on hostname?

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Switch Style based on hostname?

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply