How NOT to Optimize your Drupal website for a iPhone or iPod

Don't follow the advice posted below to "optimize" your site based on the user agent string.  The author suggests doing so in the page.tpl.php for your theme.  However, this means you can NEVER turn caching on for your site.  Also, the uses ereg functions to "detect" the device.  These functions are now deprecated by PHP, meaning they won't be supported in the future.  The matches used are also very simple, and could be done much faster using the strpos or stripos functions. 

Optimise your Drupal website for a iPhone or iPod

If you need to detect the useragent,  you should probably use hook_init() or hook_boot() to do so, since they run regardless of the cache settings.  You'd also have to plan more thoroughly how to react to different devices -  if in fact you thinkg that's a good solution.  A better approach would be to use pretty clean, flexible markup and use CSS media queries to provide device-specific stylesheets, as in Return of the Mobile Stylesheet.

Tags:

Related Items

Finally. This is a huge step forward for Drupal. After eschewing OOP practices...
I may be a bit late to the party with this observation, but web design is...
When a prominent developer and contributor lashes out that Drupal is in dire...
Matthew at DogStar describes his PM toolbox today, The Project Management...
I had a great time attending and presenting at CapitalCampDC this year, and...
Good explanation of the limitatins of using Drupal to run a multi-lingual site...

Comments

Subscribe by Email

Enter your email address:

Delivered by FeedBurner