phil.t Posted July 28, 2006 Share Posted July 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/ Share on other sites More sharing options...
ToonMariner Posted July 28, 2006 Share Posted July 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/#findComment-64925 Share on other sites More sharing options...
phil.t Posted July 28, 2006 Author Share Posted July 28, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/#findComment-64927 Share on other sites More sharing options...
legohead6 Posted July 28, 2006 Share Posted July 28, 2006 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.... Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/#findComment-64994 Share on other sites More sharing options...
king arthur Posted July 28, 2006 Share Posted July 28, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/#findComment-65082 Share on other sites More sharing options...
ToonMariner Posted July 28, 2006 Share Posted July 28, 2006 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...... Quote Link to comment https://forums.phpfreaks.com/topic/15846-determining-if-a-pocket-pcsmartphone-is-visiting/#findComment-65158 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.