Renaissauce

Wyatt Lyon Preul's Portfolio

Graffiti UserAgent Theme Switcher

January 04
by Admin 4. January 2009 12:43

Here is a package for Graffiti that allows you to specify a theme to present to an iPhone user or the Google Bot.  The package comes with a couple of themes I created for each type of user to get you started.  I originally created this to provide a more performant scenario for when a Google bot visits my site.  Google has stated on their webmaster blog that you should avoid providing different content to the Google bot other than the content you provide to a normal user.  However, I believe they are more focused on the content that is delivered, instead of how the site is laid out.  Either way, the plugin for switching themes allows you to disable either theme for the iPhone or Google.

You can download the package below:

 

 

You only need to install this through the graffiti control panel.  After this you will have 2 new themes and a new plugin installed.  You need to edit the settings on the plugin to have it running, both the iPhone and Google theme switchers are disabled by default.  Also, if you want to provide a different theme you can change the name in the settings.

The iPhone theme is from Engage Interactive with only minor tweaks.  Here is a sample of what this looks like on an iPhone, mind you I added margins and better formatting in general after this picture was taken.  I should also point out that I don't have an iPhone, so any feedback from iPhone users on how my site looks would be helpful.

image 

For any developers out there, you should note the following lines which show how simple it is to switch a theme in Graffiti inside a GraffitiEvent object.

public override void Init(GraffitiApplication ga)
{
ga.BeginRequest
+= new EventHandler(ga_BeginRequest);
}

void ga_BeginRequest(object sender, EventArgs e)
{
GraffitiContext.Current.Theme
= "MyThemeName";
}
Comments are closed