Thread: Forum Display Enhancements - Mobile Phone / iPhone / PDA Detection and Style Assignment
View Single Post
  #283  
Old 05-29-2009, 09:03 PM
CR_TurboGuy CR_TurboGuy is offline
 
Join Date: Feb 2003
Location: Iowa
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For those that want to allow the user to override the mobile style, this is what I've done on my board:

1.) Add a new profile field that allows them to set the behavior of visiting the site from a mobile device. It either uses the standard style, or the mobile style. I made it a 'Single Selection Menu', then set the two options to be 'Use Standard Version' & 'Use Mobile Version', with the default set to 'Yes, but No First Blank Option'. It's not a required field, it is editable by the user, it is a private field, it's not searchable on the Members List, and it's not shown on the member list. For the display page, I set it to 'Options: Thread Viewing' so that it shows in that section of the options page.

2.) Next, I added a few lines of code to the 'Mobile Detection' product. The code is:
Code:
if($vbulletin->userinfo['field8'] == 'Use Standard Version')
    {
          $custom1=1;
    }
Where 'field8' is what field number my custom user field is, and 'Use Standard Version' is the option to look for. If you translate the phrases to another language, you'll need to change that. You also need to change the field number to match your custom field number.
I added the above code snippet in two places, once after this block:
Code:
$exceptbrowsers = explode(",",$vbulletin->options['brows_exceptions']);
  if(preg_match('/('.implode('|', $exceptbrowsers).')/i', $_SERVER['HTTP_USER_AGENT'], $match))
    {
        $except_browser=1;
    }
and once after this block:
Code:
if ($vbulletin->options['custom1_skin_enabled'] == 1)
    {
    $custom1agents = explode(",",$vbulletin->options['custom1_skin_agent']);
    if(preg_match('/('.implode('|', $custom1agents).')/i', $_SERVER['HTTP_USER_AGENT'], $match))
      {
          $custom1=1;
      }
    }
Oh, I forgot to mention, this will use the style chosed for 'Custom/User Defined Devices Style?' in the settings for this product. I'm sure this could be extended to allow using the users default style, but on my board, there's only three styles, the 'regular' style & the mobile style for regular mobiles & one for iPhones. None are user selectable.

I'm attaching a screenshot of my new profile field, as well as a copy of the modified Mobile Device Detection & Assignment xml file. Let me know if you have any questions.

--JOsh
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02386 seconds
  • Memory Usage 1,767KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete