Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/146032-php-noob-needs-help-on-joomlaphp-coding/
Share on other sites

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  :o Duhh

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.