Hi all!
Is there any snippet that would let me insert thecontent of a chunk relatively to the browser used by the visitor? I need to change my template according to the browser to fix this damn IE! If there is no way already implemented, how to detect the browser with PHP?
thanks in advance,
Blaise
Blaise Bernier
www.medialdesign.com - Solutions for small business, hosting, design and more!
can you not just use conditional comments?
Try print_r($modx->getUserData()); it returns an array what should have browser info in it among all kinds of other stuff..
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
I’m already using conditionnal data, but the page layout needs to be modified to fix some bugs when using transparent PNGs with IE : when a background image is used and made transparent, it’s impossible to click the links in that container. So, I need to make 2 different layout for these parts to put an image behind the DIV containing the links... it’s not nice, but it’s the only way I found to make IE behave correctly. Also, I love to have small pages and adding conditionnal comments everywhere makes the thing big and dirty. That way, FireFox pages will have fully standard compliant code while IE will get the ugly code it need to work.
I found a PHP class that will make thing easy and I’ll finish the first version of my snippet soon. the class is opensource and called phpSniff. With that, my snippet will let the user select different chunks depending on the browser, JS and CSS compatibility, and many other things. I give you some news about my snippet soon!
Blaise Bernier
www.medialdesign.com - Solutions for small business, hosting, design and more!
If my logic doesn’t betray me I think you need to use Javascript to detect the browser and then pass the info back to the php.
... oh, and maybe you can bring the links to the foreground using z-index?
Quote from: grunt_lord at Feb 04, 2007, 02:50 PM
I found a PHP class that will make thing easy and I’ll finish the first version of my snippet soon. the class is opensource and called phpSniff. With that, my snippet will let the user select different chunks depending on the browser, JS and CSS compatibility, and many other things. I give you some news about my snippet soon!
Like I said, you can use $modx->getUserData(), that runs phpSniff.
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
-
☆ A M B ☆
- 24,524 Posts
check /manager/includes/sniff
Quote from: scraf at Feb 04, 2007, 03:07 PM
If my logic doesn’t betray me I think you need to use Javascript to detect the browser and then pass the info back to the php.
I heard that was actually a bad idea. some browsers like to pretend they are other broswers *cough* Opera *cough*
Here is what i’m working on :
http://modxcms.com/forums/index.php/topic,11984.msg80026.html#msg80026
It uses a PHP script to identify the browser type, so no JS hack possible and everything works even if the user is on an old or text based browser (such as Lynx).
There is a To Do list, so you can follow the evolution of the snippet!
Blaise Bernier
www.medialdesign.com - Solutions for small business, hosting, design and more!