Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-01-27 08:21:50

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: noIE popup

Hi els,

Apologies, I should have pointed you directly to example 2 of the page I linked to which reads

<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
    echo 'You are using Internet Explorer.<br />';
}
?>

I do not know if the ie specific conditional is better than php but i would (possibly naively) think that the ie conditional will always be part of the ‘visible’ code whereas php will only show the message if the condition is met.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#14 2008-01-27 08:31:50

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: noIE popup

PHP is not recommended for this kind of thing.

The comment was dealing the fact of using libraries, and only calling funtions in html, not actually prosssing the function inside html. That is just matter of maintain. I don’t actually get it why that completely unrelated comment was there.

But those <!--[if lte IE 6]><![endif]--> shouldn’t be actually used, as you might in somepoint see. In example they don’t parse everything correctly like javascript, comments or styles: in IE6 ofcourse. But that’s only when you want hide things from IE.

So, the PHP snippet is the key answer.

<txp:php>if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) echo 'You are using Internet Explorer.';</txp:php>

Cheers!

Last edited by Gocom (2008-01-27 08:33:33)

Offline

#15 2008-01-27 09:03:29

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: noIE popup

hi gogom, in the cod I pasted there’s a brace after FALSE) and another one at the end of the snippet whereas in yours there aren’t any. Which one is correct?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#16 2008-01-27 09:08:46

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: noIE popup

its only a single line after the if conditional. you don’t need any braces.

Offline

#17 2008-01-27 12:21:10

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: noIE popup

iblastoff said it ;)

Cheers!

Offline

#18 2008-01-27 12:55:01

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: noIE popup

Thanks all! How would the code be if I wanted to distinguish between IE7 and IE6 or less? And should I also use PHP in the head instead of <!--[if lte IE 6]><![endif]--> to link to the style sheets?

Last edited by els (2008-01-27 13:29:08)

Offline

#19 2008-01-27 16:01:11

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: noIE popup

And should I also use PHP in the head instead of <!—[if lte IE 6]><![endif]—> to link to the style sheets?

You can use those for stylesheets. It’s stylesheet not hidden content :)

Thanks all! How would the code be if I wanted to distinguish between IE7 and IE6 or less?

By adding there the version number after the MSIE.

Example value: MSIE 5.0, MSIE 5.5, MSIE 6.0 and MSIE 7.0

<txp:php>if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0') !== FALSE) echo 'You are using Internet Explorer.';</txp:php>
<txp:php>if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0') !== FALSE OR strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== FALSE) echo 'You are using Internet Explorer.';</txp:php>

Cheers!

Last edited by Gocom (2008-01-27 16:01:56)

Offline

#20 2008-01-27 16:05:54

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: noIE popup

Thank you very much Gocom! :)

And if I want to exclude IE, can I just use == instead of !== ?

Offline

#21 2008-01-27 16:15:25

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: noIE popup

And if I want to exclude IE, can I just use instead of ! ?

Er, no – it’s just a conditional. If you change that to == then it output that conditional contest when browser is anything else than IE.

If you want completely exclude, meaning block IE, you could use die/exit. In example:

<txp:php>if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) exit("Sorry Boris, you're using IE. No access to my site with your browser.");</txp:php>

Cheers!

Last edited by Gocom (2008-01-27 16:16:08)

Offline

#22 2008-01-27 16:49:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: noIE popup

Gocom wrote:

Er, no – it’s just a conditional. If you change that to == then it output that conditional contest when browser is anything else than IE.

That’s what I meant :) Just hide some content that doesn’t work in IE6.

Offline

Board footer

Powered by FluxBB