Making blogs look better on Windows Mobile

WordPress
Comments Off on Making blogs look better on Windows Mobile

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…