Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2005-09-09 02:16:29
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
Plugin request: php/server based browser detect conditional
I don’t know about the rest of you – but I am getting a bit tired having to employ various ugly CSS hacks to get my designs working reasonably across most browsers. And even with all the hacking in the world I dread what some poor person looking at some of my sites with Win98 IE4 gets… I guess you could say “who cares…” but then I know a few mum and dad type users who still have that exact browsing combination.
Looking through my logs got me thinking that a neat solution would be a PHP/server based detection plugin. I know CSS but I do not know PHP – hence the request.
I would see it working as a conditional <code><txp:browser_detect agent=“ie6,nn7,ff1”>Load modern CSS</txp:browser_detect> </code> and then <code><txp:browser_detect agent=“ie4equiv”>load primative CSS</txp:browser_detect></code>
Maybe it could be simplfied by an array defined in the plugin to lump browsers into 2 or 3 groups: (<= ie4,nn4) (ie5,5.5) (ie6+) not sure…
Anyone keen to have a go
(Maybe I should learn PHP!)
SH
Offline
Re: Plugin request: php/server based browser detect conditional
I’m working on a plugin that tracks visitors, which detects the browser they’re using. You’ll be able to display the browser name using a tag like <txp:hit_logger_browser>
, but this isn’t so useful. I’ve been considering a conditional like you mentioned (I like the idea of comma separated values!).
The problem is that I currently map the browser into a small group of values. For example, “mozilla/4.x” turns into “Netscape Navigator 4”. It’s actually 13 versions of the browser, turned into a single value for displaying. Plus it’s a rather long string to deal with.
I’ll look into adding proper version information for the browsers and perhaps a 3 or 4 character “nickname”, then implementing a <txp:hit_logger_if_browser>
tag.
Are Textpattern tags allowed in CSS files?
[Lee]
Monkeys could have written a better post..
Offline
#3 2005-09-09 03:39:29
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
Re: Plugin request: php/server based browser detect conditional
Good to see.
I think that a good start would be specify a few obvious browser groups. I reckon:
- IE 4.0, NN 4.0 and anything similar / older
- IE 5, 5.5 (due to it’s box model bug)
- IE 6
- Decent browsers (inc FF, Safari)
The nickname idea sounds good – but it might be a pain if you have to specify all of them in a conditional statement…
The tag would be placed in the HTML between the <code><head></code> tags to load different CSS files as needed. The plugin would have to have another attribute to specify the TXP name of the CSS file.
As you can see – I’m full of ideas – and no ability to implement them :)
SH
Offline
Re: Plugin request: php/server based browser detect conditional
i actually serve 2 different css files using some css hackery.
in the main css file i have
@import ‘advanced.css’;
and then basic formatting rules, such as fonts and colors.
advanced.css has all the layout stuff
4.x browsers (and ie 5 mac) get only the basic css, the rest get all of it.
~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~
Offline
Re: Plugin request: php/server based browser detect conditional
Can I suggest to you, Virtruvius, that for now, at least while such a pluggin does not exist, that if you are trying to server alernate style sheets depending on browser type that you use Internet Explorer conditionals. Like this:
<code><!—[if IE]><style type=“text/css” media=“screen”>/* <![CDATA[ / @import url(/styles/iepc.css); / ]]> */</style><![endif]—></code>
There are also a lot of various filters that you can use which would still let you keep your main stylesheet (the one that works like it should) clean. I personally use the conditional statement for my photoblog.
All this being said, if i could find a list of browser versions, as they would come up in php, I would be willing to spend some time developing a plugin like this. My main stopping point at this moment is finding a list of the browser versions as they’re seen by php.
Last edited by akokskis (2005-09-09 14:17:00)
Offline
Re: Plugin request: php/server based browser detect conditional
akokskis, maybe this would be a starting point:
http://www.stylegala.com/articles/no_more_css_hacks.htm
~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~
Offline
Re: Plugin request: php/server based browser detect conditional
Well, I don’t know so much about CSS (although this IE box model problem might explain the problem with the footer of my site). I do know PHP and have been working on a plugin that has logic for detecting browsers.
Since this is really a logger, I just wanted a generic string to identify things (as I said, I often map a bunch of different version into one value). I could easily enhance this, it’s more of a data entry issue than a coding issue. I can poke around and see what documents are available, I suspect the best would be Gary Keith’s browscap files.
Vitruvius, you can download my plugin and look through the source of hit_logger to see what I use to distinguish different browsers (basically a database look up table). It could be the start of your own plugin. Or you can wait until I’m done, perhaps a week.
[Lee]
Monkeys could have written a better post..
Offline
Re: Plugin request: php/server based browser detect conditional
Hey there folks, for whatever it’s worth, my development of a plugin for detecting browsers is nearly close enough to release for public use. Still need to do some testing, but once that’s done, it’ll be out for all.
Offline
#9 2005-09-10 00:57:45
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
Re: Plugin request: php/server based browser detect conditional
kemie, I think the stylegala article you quote could be a good starting point. I had read it and then couldn’t find it again when I came to post initially :) I think the thing that could be taken is the browser detection code. I personally would not like to follow the example where php is inserted into inline CSS. I’d prefer a simple TXP plugin to load in a different CSS file based on conditions.
LeeStewart – I’ll have a look shortly – although I don’t have the foggiest about php.
akokskis, I have used the <code><!— [if IE] —></code> conditionals before – but mainly to display a message saying “get Firefox”! The problem is that IE 6 is basically fine in CSS but IE 5.x are a pain in the **** (here is a summary). Fantastic to see you are developing a plugin – I’d be happy to help with testing as I have a PC and Mac next to each other with almost all browsers for each ;)
Offline
Re: Plugin request: php/server based browser detect conditional
I’d like to announce my newest plugin, ako_ifBrowser . Check out the help file for more info here
Last edited by akokskis (2005-09-10 03:27:29)
Offline