Jump to content


Photo

Determining if a Pocket PC/Smartphone is visiting


  • Please log in to reply
5 replies to this topic

#1 phil.t

phil.t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 July 2006 - 12:57 AM

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.

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 July 2006 - 01:11 AM

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.
follow me on twitter @PHPsycho

#3 phil.t

phil.t
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 28 July 2006 - 01:21 AM

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?

#4 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 28 July 2006 - 05:24 AM

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....
"Syntax error" .. WHERE THE **** IS IT?!

#5 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 28 July 2006 - 10:24 AM

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: http://www.phpfreaks...et-browser.html
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#6 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 July 2006 - 02:10 PM

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......
follow me on twitter @PHPsycho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users