A phpBB 3 iPhone Style Theme With Option to Disable

phpBB iPhone theme styleA forum that I am an adminstrator for has been clamoring for an iPhone theme (style) for a long time now. In the past, I hadn’t seen any usable iPhone template for phpBB3, until now.

The theme is hosted on Google code and is named phpbb-iphone-style. It is downloadable here and was last updated June 18th, as of today.

The theme works wonderfully on the iPhone. However, the issue that I ran into is automatically displaying it for mobile browsers, such as the iPhone, Android and other platforms.

Fortunately there is a modification you can make to the phpbb code which is effectively a theme switcher for mobile browsers. The how to is located within the download file for the theme above.

What if a user wants to turn off the mobile style?

I modified the code to allow a user to set an option on their profile to permentently disable the theme when logged in on a mobile browser.

First, install the style as described above. As part of the switcher, you need to find out the theme ID. You can do so, after installing the style, by hovering over the ‘Detail’ tab in the ACP (Administrator Control Panel) and looking for the ‘id’ variable. In the example below it is ‘6’.

Once the theme is installed, move over to the “Users and Groups” tab, and then the “Custom Profile Fields” area. At the bottom of this page there is a box to add a new profile field. Type ‘disable_mobile’ as the name, and Boolean (Yes/No) as the type and click add.

For the options, I selected:

  • Publicly display profile field: No
  • Display in user control panel: Checked
  • Display on registration screen: Unchecked
  • Display on viewtopic screen: Unchecked
  • Required field: Unchecked
  • Hide profile field: Unchecked
  • Field name/title presented to the user: Disable Mobile Browser
  • Field description: When viewing on a mobile device (iPhone, Android, etc), clicking ‘yes’ will disable the mobile browser.
  • Entries: First option: Yes, Second option: No

On the second screen select the following items:

  • Field type: Radio Buttons
  • Default value: no

Save your custom profile field.

It will end up looking like this in the profile control panel of the end user:

phpbb iphone style disabler

Now the fun part, adding the code to your install to select which mobile browser to use automatically.

Back up, then open install dir/includes/session.php

Around line 1468 in the function setup

[cc first_line=”1468″] /**
* Setup basic user-specific items (style, language, …)
function setup($lang_set = false, $style = false)


global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;


global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache, $user;

//-----Begin phone detection & redirection code-----

$user->get_profile_fields( $user->data['user_id'] );
$user_fields = $user->profile_fields;

// if (!($user_fields['pf_disable_mobile'] == 1)) {
// Thanks to Chris Dembek for this code fix
if (isset($user_fields['pf_disable_mobile']) && !($user_fields['pf_disable_mobile'] == 1))

//id of the iphone/mobile theme - SELECT THIS FROM YOUR STYLES
$mobilestyleid = 6;

//Fetch the users browser
$user_browser = strtolower($this->browser);

//List of mobile user-agent keywords
$browsers_array = array('240x320', '320x240','blackberry', 'iemobile', 'minimobile', 'mobile', 'opera mini', 'pda', 'phone', 'pocket', 'psp', 'symbian', 't-shark', 'wireless');

//Check for the user-agent in the list of mobile user-agents
foreach ($browsers_array as $ua_match) {
if (strpos($user_browser, $ua_match) !== false) { //a match
$style = $mobilestyleid;
$this->data['is_mobile'] = true;


//-----End phone detection/redirection code-----

Make sure to replace $mobilestyleid = 6 with your style id number!

Save your file. Test out the modifications on your phone, you should be presented with the mobile version on reload (make sure to purge any cache if you don’t see it right away).

Finally go into your profile and select the ‘disable mobile browser’ option and make sure it reverts back to your regular default theme.

Let me know if you have any problems implementing this but it has worked great for this phpbb forum!

Dave Drager

Dave Drager


Sign in or become a free systemBash member to read and leave comments.
Just enter your email below to get an easy log in link.