Using the same exact code:
{exp:browser_sniff}
{if browser_name=="saf"}
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=include/safari}" />
{/if}
{/exp:browser_sniff}
It shows the stylesheet in the code in FF3 on XP. Am I behind on the version? Running v1.2.
Hi,
Using the same exact code:It shows the stylesheet in the code in FF3 on XP. Am I behind on the version? Running v1.2.{exp:browser_sniff} {if browser_name=="saf"} <link rel="stylesheet" type="text/css" media="all" href="{stylesheet=include/safari}" /> {/if} {/exp:browser_sniff}
Trying your code with Firefox 3 on Windows XP I was unable to replicate the effect you described. That is, the result was as expected - no output.
The issue is not somehow connected with version 1.2 because all versions of Browser Sniff plugin use exactly the same code for browser recognition.
Is it possible that your template code is cached and that’s the reason why you get the same results for both browsers?
That should not be the reason.
Browser Sniff plugin recognizes which browser is used by parsing $_SERVER[‘HTTP_USER_AGENT’] variable. Plugin outputs {browser_name} as “saf” in case $_SERVER[‘HTTP_USER_AGENT’] variable converted to lowercase contains substring “safari” and it outputs {browser_name} as “moz” in case $_SERVER[‘HTTP_USER_AGENT’] variable converted to lowercase contains substring “gecko”.
Here is what $_SERVER[‘HTTP_USER_AGENT’] variable outputs in case browser is Firefox 3 on Vista:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Here is what $_SERVER[‘HTTP_USER_AGENT’] variable outputs in case browser is Firefox 3 on XP:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
As you can see there is no substring “safari”. This is the reason why the code
{exp:browser_sniff}
{if browser_name=="saf"}
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=include/safari}" />
{/if}
{/exp:browser_sniff}
outputs nothing, as it should, both for Firefox 3 on Vista and on XP.
Have you thought about extending this to support mobile browser sniffing? I’ve found a gazillion different chunks of PHP that purport to figure out whether the user’s on a mobile or not so they can be redirected to the right pages and/or styled differently. That would be a useful addition.
Have you thought about extending this to support mobile browser sniffing? I’ve found a gazillion different chunks of PHP that purport to figure out whether the user’s on a mobile or not so they can be redirected to the right pages and/or styled differently. That would be a useful addition.
Currently Browser Sniff plugin is quite weak. It recognizes several most known browsers and that’s all.
It would be good to extent its capabilities. One possible solution would be to base Browser Sniff plugin on CodeIgniter’s User Agent class.
Unfortunately as yet I have no experience in CodeIgniter’s framework. I will consider this when ExpressionEngine 2.0 based on CodeIgniter will be released and when I will upgrade my plugins to be compatible with it.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.