Drupal 6: Configuring a mobile Drupal site and making your theme mobile friendly
In this tutorial I’ll explain how to setup your Drupal site to be mobile friendly. Before you begin, it’s helpful to consider the following: 1) which mobile devices to support; 2) using a different theme for mobile; 3) which hostnames will be used; 4) multi-site configuration options; and 5) any site alterations to simplify the mobile experience.
redirect mobile traffic to a new subdomain (mobile.ericlondon.com)
I was using sites/default for my blog, so hosting another hostname on the same filesystem was not an issue
I decided to remove some items in my primary navigation, and add some jQuery (accordion effect) to collapse node content on my front page.
I added the new DNS for my subdomain to point to the same IP address of my main site. In a standard Apache vhosts configuration, you can add a ServerAlias directive to ensure the mobile hostname is handled by the main site’s vhost. For example:
I installed and enabled the Singular theme in sites/all/theme/singular.
I added some mobile specific configurations in my settings.php file (sites/default/settings.php):
Now if someone visits my site using an iPhone, the user would be redirected to my specified mobile address, AND a new mobile theme would be used!
In addition I decided to make some alterations to my mobile theme to simplify the interface. I created a module and added a hook_preprocess_page() implementation:
By added the above module code and jQuery, I removed some items from my primary navigation and added an accordion-like interface for the front page:
NOTE: If you’re using a Mac, the iPhone Simulator application (which comes with Xcode + iPhone SDK) is a great way to development and test mobile configurations.