User Agent / Browser detection

Author Message

Dries Samyn

Thursday 27 May 2004 7:38:42 am

Does anybody know if there is a way to detect the user agent. $_SERVER['HTTP_USER_AGENT'] in PHP. I'd like to build a stylesheet selector so I can serve an alternative stylesheet for NS4 browsers.

Cheers,

Dries.

Alex Jones

Thursday 27 May 2004 8:21:54 am

Actually, I already have one working on a few different eZ publish sites. I will post it today, once I have written a few instructions.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Alex Jones

Thursday 27 May 2004 8:57:23 am

Okay, check out the eZBrowserSniff Operator in the Contributions section of the site: http://ez.no/community/contributions/template_plugins/ezbrowsersniff_operator . Please note, Paul Forsyth provided a tremendous amount of help on this. :)

I will try to clean up the package as I have time. But this should work for you.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Bruce Morrison

Thursday 27 May 2004 11:43:20 pm

Hi Dries

I think you can do this just using CSS hacks

NS4 doesn't reconnise the @import of style sheets while most other do.

This allows you to do something like

<link rel="stylesheet" type="text/css" href="/path/to.css">
<style type="text/css">
	@import url(/path/toadv.css);
</style>

to.css will be read only by NS4, while other browsers will read both.

Cheers
Bruce http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Dries Samyn

Friday 28 May 2004 1:24:32 am

Thanks Bruce,

However, the CSS hack is just that, a hack. I don't like it at all because it forces the users of "good" browsers to download an extra stylesheet that was written for people with rubbish browsers (NS4), making the total page size bigger.
Main reason why I want seperate stylesheets is because I want to use relative font sizes, and NS4 makes an absolute mess of that. I always build my sites that way, one stylesheet for NS4, one for all other browsers.

Bruce Morrison

Friday 28 May 2004 7:22:45 pm

> However, the CSS hack is just that, a hack.
And browser dectection isn't? ;)

I'm curious as to why are are going to the trouble to support NS4? Is it it is a specific requirement?

We use the @import method are don't bother with style sheets for NS4 users - they get the unstyled version of the site. We make sure the unstyled version of the site is still usable (important for screen readers etc).

Cheers
Bruce http://www.designit.com.au

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Ekkehard Dörre

Saturday 29 May 2004 2:15:01 am

Hi,

there are different methods:
in German:
http://www.lipfert-malik.de/webdesign/tutorial/css.html#Browserweichen

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Lazaro Ferreira

Monday 12 June 2006 9:05:33 am

Hi ,

Have any body used this operator for WAP browser detection ?

It seems to me a good approach to use this operator to detect request from wap browser and redirect ezpublish to the right siteaccess, i.e. http://mydomain/wap

I would like to know your opinion on this

Thanks

Lazaro
http://www.mzbusiness.com

André R.

Monday 12 June 2006 11:05:45 am

You don't have to redirect wap browsers.
If you have your templates in xhtml strict/ basic, you only need a different css file for handhelds.
Of course this means it would not work in wap 1 - 1.3 phones, only wap 2.0 (= xhtml basic).
But supporting wap 1 is like supporting NS4, a lot of work for 0.001% users who should have upgraded a long time ago anyway.

About number of NS4 users, look here: http://www.w3schools.com/browsers/browsers_stats.asp
There are 0.3-0.4% Netscape users, probably 90% of those are using Netscape 7(look at the n7 number from last year).
Netscape 8 is using mozilla and internet Explorer engines, so probably shows up as those.

When it comes to wap 1, wap 2.0 came around three years ago. Most people change their phone ever year or at least ever secon year...
Only reason to redirect phone users would be to present different content.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Lazaro Ferreira

Tuesday 13 June 2006 3:34:19 am

Hi Andre,

I'm aware of what you said, but the issue here is not redirecting but detecting browsers capabilities (PDA,WAP,XHTML, etc) and serving customized content , my model is
nokia.com , where you can browse from mobile or PC, and behind the scene you are redirected to the right URL in order to get the best experience as a visitor

Lazaro
http://www.mzbusiness.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.