AJAXify your Wordpress

Learn how I ajaxified my wordpress blog with these few steps...

SBS Show!

Listen to the latest episode of the SBS Show, Dave Sobel talks about process management...

Vladville Newsletter!

Looking for a more focused, exclusive insight into the world of SMB tech & business? Sign up for my newsletter!

Making blogs look better on Windows Mobile
Posted: 5:12 pm
December 17th, 2007
Post a comment
WordPress

As I continue to tweak Vladville to fit in better with the upcoming Thieving Weasel framework, I decided to put in a little bit of work to make Vladville easier to navigate on Windows Mobile devices. Pulling up Vladville on a Windows Mobile (PocketPC or Smartphone) will now only display the content, sans the Javascript, AJAX, sidebar, slidey stuff or other blog gunk that you see in the full featured web page because.. well.. it’s what I do. Pull it up and see, hopefully this makes Vladville a little more pleasant in the pocket. It took all my might not to call it PocketVlad, for what its worth.

It’s a very quick Wordpress loop hack that excludes certain form elements from the display when the browser is Windows CE based:

if(!strpos(”$_SERVER[HTTP_USER_AGENT]“,”Windows CE”))

{ display regular content to IE, FF, Opera.. }

Wordpress checks the UserAgent sever variable for presence of Windows CE and if it doesn’t find it, it prints the regular blog content. However, if it finds out that you are on Windows CE it does not send the particular content to it.

So for example, let’s say your template code includes a like like <?php get_sidebar(); ?> and your sidebar has all that gunk useless to a mobile viewer? Just wrap it and it will not be displayed to the Windows Mobile browser:

if(!strpos(”$_SERVER[HTTP_USER_AGENT]“,”Windows CE”)) { get_sidebar(); }

What if you had some HTML markup like things you copied and pasted from the web site to include a comic, calendar or 8,285 buttons and ways to subscribe or share your posts?

<div id=’blah’>Blah blah blah</div>

Same thing, but a little different:

<? if(!strpos(”$_SERVER[HTTP_USER_AGENT]“,”Windows CE”)) { ?>
   <div id=’blah’>Blah blah blah</div>
<? } ?>

Gotta love the simplicity of PHP. Just put line #1 above the content you want to block from Windows Mobile and below. Now, naturally, you have to have the markup elements match up because if you cut your table or div elements in half your layout will fall apart.

Still, pretty easy to make Wordpress friendly with Windows Mobile…

Leave a Reply

OpenID

Anonymous






 

Categories

 

Archives

 

About

Divider Divider