cqinzx Posted February 19, 2009 Share Posted February 19, 2009 Hey PHP Freaks, I think you guys are fantastic for helping out noobs like me.. Well I'm here because I need some help with some Joomla/php coding. I'm using this Joomla extension called MetaMod. Theres nothing wrong with the module, but the module requires PHP knowledge, which is what I don't have. I'm trying to display a certain module in all browsers except Internet Explorer. I saw some MetaMod PHP recipies on the Documentation page, but I didn't know what to do with. I know I'm suppose to copy and paste the code, but I don't know how to edit the code so that the module won't show up in IE. Can you help me out? Heres the code if you guys need it: // browser detection example (display a different module based on which browser is being used) $UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $SF = strstr($UA, 'Safari') ? true : false; $OP = strstr($UA, 'Opera') ? true : false; $OPV = $OP ? preg_split('/opera\//i', $UA) : false; $OPV = $OPV ? floatval($OPV[1]) : false; $FF = !$OP && strstr($UA, 'Firefox') ? true : false; $FFV = $FF ? preg_split('/firefox\//i', $UA) : false; $FFV = $FFV ? floatval($FFV[1]) : false; $IE = strstr($UA, 'MSIE') ? true : false; $IEV = $IE ? preg_split('/msie/i', $UA) : false; $IEV = $IEV ? floatval($IEV[1]) : false; if ($IEV >= 7) return 55; // any version of IE greater or equal to 7 if ($IEV >= 6) return 55; // any version of IE greater or equal to 6 if ($IE) return 55; // any version (at all) of IE if ($OP) return 66; // any version of Opera if ($FF) return 77; // any version of Firefox if ($SF) return 88; // any version of Safari And here is the Documentation page The reason I want to block IE is because IE can't handle the Javascript that is in the module(JW Player) I'm using. Thanks for helping out in advance. Quote Link to comment https://forums.phpfreaks.com/topic/146032-php-noob-needs-help-on-joomlaphp-coding/ Share on other sites More sharing options...
jackpf Posted February 19, 2009 Share Posted February 19, 2009 This code will get you the browser- $browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(ereg('msie', $browser)) { echo 'You are using ie'; } else if(ereg('firefox')) { echo 'You are using ff'; } Enjoy. Quote Link to comment https://forums.phpfreaks.com/topic/146032-php-noob-needs-help-on-joomlaphp-coding/#findComment-766661 Share on other sites More sharing options...
cqinzx Posted February 21, 2009 Author Share Posted February 21, 2009 Thanks a lot Jack! Quote Link to comment https://forums.phpfreaks.com/topic/146032-php-noob-needs-help-on-joomlaphp-coding/#findComment-767925 Share on other sites More sharing options...
jackpf Posted February 21, 2009 Share Posted February 21, 2009 No problem JUST REALISED! $browser = strtolower($_SERVER['HTTP_USER_AGENT']); if(ereg('msie', $browser)) { echo 'You are using ie'; } else if(ereg('firefox', $browser)) { echo 'You are using ff'; } That will work. I forgot to set the string to check for the ereg in firefox Duhh Quote Link to comment https://forums.phpfreaks.com/topic/146032-php-noob-needs-help-on-joomlaphp-coding/#findComment-767963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.