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.

eZ debug

Timing: Jan 19 2025 04:34:00
Script start
Timing: Jan 19 2025 04:34:00
Module start 'layout'
Timing: Jan 19 2025 04:34:00
Module start 'content'
Timing: Jan 19 2025 04:34:01
Module end 'content'
Timing: Jan 19 2025 04:34:01
Script end

Main resources:

Total runtime1.1871 sec
Peak memory usage4,096.0000 KB
Database Queries86

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 590.6016152.6250
Module start 'layout' 0.00630.0024 743.226639.4453
Module start 'content' 0.00871.1767 782.6719789.7031
Module end 'content' 1.18540.0017 1,572.375024.1641
Script end 1.1871  1,596.5391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2724160.0002
Check MTime0.00140.1204160.0001
Mysql Total
Database connection0.00110.093210.0011
Mysqli_queries1.095992.3144860.0127
Looping result0.00140.1218840.0000
Template Total1.152797.120.5764
Template load0.00190.161120.0010
Template processing1.150896.937120.5754
Template load and register function0.00020.016210.0002
states
state_id_array0.00110.091610.0011
state_identifier_array0.00110.091620.0005
Override
Cache load0.00180.1503650.0000
Sytem overhead
Fetch class attribute can translate value0.00070.055960.0001
Fetch class attribute name0.00150.1248140.0001
XML
Image XML parsing0.00260.219460.0004
class_abstraction
Instantiating content class attribute0.00000.0029160.0000
General
dbfile0.00210.1753350.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 46
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs