Home : Products : Gossamer Forum : Development, Plugins and Globals :

Products: Gossamer Forum: Development, Plugins and Globals: Re: [Boomer] Forum Runner or Tapatalk for our forum software?: Edit Log

Here is the list of edits for this post
Re: [Boomer] Forum Runner or Tapatalk for our forum software?
Hi,

To be honest - most "smart phones" actually cope fine with web-pages as they are. Agreed, it would be cool to have a way of "simplifying" the pages to make them more friendly to phone users (i.e less CSS less images, nicer layout, etc)

One way of doing that - would be to duplicate the template set you use, and then access it via t=xxxx from the URL. You could also go as far as writing a little bit of Perl to work out if they are using a smart device, and then re-derect accordingly. Something like they have here:

http://www.brainhandles.com/...ting-mobile-browsers

A quick conversion of that into Perl, would look something like: (totally untested!);

Code:
sub checkmobile {

if($ENV{HTTP_X_WAP_PROFILE}) { return 1; }

if($ENV{HTTP_ACCEPT} =~ /wap\.|\.wap/i) { return 1; }

if($ENV{HTTP_USER_AGENT}){

if ($ENV{HTTP_USER_AGENT} =~ /OfficeLiveConnector|MSIE 8\.0|OptimizedIE8|MSN Optimized|Creative AutoUpdate|Swapper/) { return 0; }

my @other_phones = ("midp", "j2me", "avantg", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/", "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC", "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto","webos");

foreach (@other_phones) {
if($ENV{HTTP_USER_AGENT} =~ /$_/) { return 1; }
}

}

return 0;

}

Simply call with (in gforum.cgi):

Code:
if (checkmobile()) {
$IN->param('t' => "mobile_template" );
} else {
# carry on normally, and show the standard templat eset
}

Hope that helps

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Oct 31, 2011, 3:39 AM

Edit Log: