Jump to content

Archived

This topic is now archived and is closed to further replies.

phil.t

Determining if a Pocket PC/Smartphone is visiting

Recommended Posts

My site looks less than flattering on a Pocket PC / Smartphone; so I want to alter the display based on whether the site is being viewed from a web browser on a computer (greater than 800x600 resolution) or whether it's being viewed by a smaller hand-held device.

My question is this: How do I go about determining this information?  Is there a PHP global I need to check? Or is there another generally accepted method for determining this?

Thanks,
Phil.

Share this post


Link to post
Share on other sites
Ths simple answer is to create a style sheet for handheld devices.....

This is how some of my bigger sites css is declared.....

<link href="/global/css/screen/screen1.css" rel="stylesheet" type="text/css" media="screen">
<link href="/global/css/braille/braille.css" rel="stylesheet" type="text/css" media="braille">
<link href="/global/css/aural/aural.css" rel="stylesheet" type="text/css" media="aural">
<link href="/global/css/handheld/handheld1.css" rel="stylesheet" type="text/css" media="handheld">
<link href="/global/css/print/print1.css" rel="stylesheet" type="text/css" media="print">
<link href="/global/css/tv/tv1.css" rel="stylesheet" type="text/css" media="tv">

There is a style sheet there for every type of device that cn view your site.  You just need to add the media attribute to let the client know which sheet it should use.

Share this post


Link to post
Share on other sites
Thanks, this is great information.

In my current application however, I use CSS for simple text formatting (colors, fonts, etc) and a template engine (Smarty) for layout.  My intention was to create a separate template for handheld devices; when a visitor comes I check which category they fall into and direct output to the appropriate template.

Any further advice on how I would check in this instance?

Share this post


Link to post
Share on other sites
you would have to use javascript or something to determin browser information and find out what brower infomation... then go on from there... but im not any good at js anymore so you would probably have to look elsewhere for this code....

Share this post


Link to post
Share on other sites
You can get the user agent from $_SERVER['HTTP_USER_AGENT'] - this contains a string relating to the browser configuration, I believe from that you can extract the browser type and operating system.

EDIT: Try looking up the get_browser() function here: [url=http://www.phpfreaks.com/phpmanual/page/function.get-browser.html]http://www.phpfreaks.com/phpmanual/page/function.get-browser.html[/url]

Share this post


Link to post
Share on other sites
All these are well and good BUT....

You can save yourself a lot of work and hassel by producing a site has semantic markupand then simply use the css methods I described earlier.

Not done much with smarty templates but if you can edit them yourself and create a layout that has no in-line styling (such has height width padding etc.) and simply give elements a class or id then this would be a site that would (could) look good in all clients and be 3000000 times easier to manage......

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.