[Zope] pc - vs - mac

Phil Harris phil.harris@zope.co.uk
Thu, 16 Dec 1999 12:46:28 -0000


Here's some dtml I use for this purpose.

It could probably be extended, but it works for me.


<dtml-call "REQUEST.set('ua',HTTP_USER_AGENT)">

<dtml-if "_.string.find(ua,'MSIE') != -1">
 <dtml-comment>
  Its MSIE
 </dtml-comment>
 <dtml-call "REQUEST.set('bMSIE',1)">
 <dtml-if "_.string.find(ua,'MSIE 3.0') != -1">
  <dtml-call "REQUEST.set('bMSIE3',1)">
 </dtml-if>
 <dtml-call "REQUEST.set('iMSIE4',_.string.find(ua,'MSIE 4.0'))">
 <dtml-if "iMSIE4 == -1">
  <dtml-call "REQUEST.set('iMSIE4',_.None)">
 </dtml-if>
 <dtml-if iMSIE4>
  <dtml-call "REQUEST.set('bMSIE4',1)">
 </dtml-if>
 <dtml-if bMSIE4>
  <dtml-call "REQUEST.set('minorVer',ua[iMSIE4+8])">
  <dtml-if bMSIE4>
   <dtml-if "minorVer == 'p' or minorVer == 'b'">
    <dtml-call "REQUEST.set('bMSIE4_beta',1)">
   </dtml-if>
   <dtml-if "minorVer == '1'">
    <dtml-call "REQUEST.set('bMSIE4_01',1)">
   </dtml-if>
  </dtml-if>
 </dtml-if>
 <dtml-if "_.string.find(ua,'MSIE 5') != -1">
  <dtml-call "REQUEST.set('bMSIE5',1)">
 </dtml-if>
<dtml-else>
 <dtml-comment>
  Let's assume netscape
 </dtml-comment>
 <dtml-call "REQUEST.set('bNetscape',1)">
 <dtml-if "ua[8] >= '4'">
  <dtml-call "REQUEST.set('bNetscape_4',1)">
 <dtml-elif "ua[8] >= '3'">
  <dtml-call "REQUEST.set('bNetscape_3',1)">
 <dtml-else>
  <dtml-call "REQUEST.set('bNetscape_2',1)">
 </dtml-if>
</dtml-if>

HTH

Phil
phil.harris@zope.co.uk


----- Original Message -----
From: Kyle Burnett <kburnett@ep.newtimes.com>
To: <zope@zope.org>
Sent: Friday, December 17, 1999 12:31 AM
Subject: [Zope] pc - vs - mac


> so we want to serve up a differnet element depending on the user's
platform.
>
> has anyone tried this in zope? is a simple javascript the answer or is
there
> a zope method to accomplish this?
>
> thanks,
> kyle
> http://www.newtimes.com
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>