Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

return for XXX for IE (any version)

return for XXX for IE (any version)

Hi guys!

Great module!  Even the free one does a lot of stuff which doesn't happen to often.

What I'm trying to do is show nothing if you are any version of IE, and show this one module if you are anything but IE (so, that means the rest)

this is what I have from reading the recipes and forum posts.  from what I have, all I'm seeing is module 19 in both IE and Firefox.


$UA  = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$CH  = strstr($UA, 'Chrome/') ? true : false;
$CHV = $CH ? preg_match('#Chrome/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)#',
         $UA, $matches) : false;
$CHV = $CHV ? $matches[1] : false;
$IP  = strstr($UA, 'iPhone') ? true : false;
$SF  = !$CH && 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  = 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;


// Customize the module return numbers as you wish

if ($IE) return 16; // any version of IE
return 19; // any other browser

Edited By: tokenring
28-Apr-10 01:06:52

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

to me there should be an *else*, but I'm new to this.

Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

the only reason why I define all of them is because I will later on do something for each browser.  For now I want all types of IE to see one module, and the rest see one.

Thanks,
Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

Hi Aaron,

in this case, the else is not necessary. If the $IE is true, then execution never reaches the next line, as the value 16 is returned, and execution finishes.

Your problem seems to be that Explorer is not triggering $IE to be "true".

Can you try this simplified version of the rule, which also prints out some diagnostics?

$UA  = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$IE  = strstr($UA, 'MSIE') ? true : false;
echo "USER AGENT STRING: $UA <br />";
if ($IE) return 16; // any version of IE
return 19; // any other browser

Now, view the page in IE and in Firefox.
When you view it in IE, what's the output of the MetaMod? It should give a long string. Does it include the exact characters "MSIE" in it somewhere? If not, then that's the reason. If it is, then something else is going on. Try turning on Debug mode in MetaMod to see which module it thinks it's including.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

Thanks so much Stephen.  I'll try that now and get back to you.


Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

Hi Guys!

Okay, IE is now showing the one module and FireFox is showing the other as expected, but it seems that they both spit out the same debug.

IE debug
USER AGENT STRING: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

FireFox debug
USER AGENT STRING: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

so I don't understand how each browser knows what to display.  Also, it is intermittent that both are showing the correct/wrong one at times... even after clearing the cache in the browsers and in the Joomla control panel.


Is there a way for metamod to do the following?

if browserA return x
any other browser return NULL (not even show the metamod)


The reason why I am asking and why I am even using metamod is because there is this template I am using (author of it not getting back to me, neither is the author of IE Compatibility) that puts boxes around the modules when they are published and they are not showing up in IE correctly.  So in the combination of IE compatibility and Metamod, I thould I would be able to resolve this, but I haven't.    Let me know

Thanks for the help though as I really appreciate it. 


Aaron

tokenring
Beginner Modder
ranks
useravatar
Offline
9 Posts
Administrator has disabled public posting

Re: return for XXX for IE (any version)

Hi Aaron,

I bet I know what's going on - you probably have the System cache plugin turned on. This is what causes the intermittent changes in the output, and the debug output that seems to be the same for both browsers.

Joomla has 2 cache mechanisms. There's the one that's turned on the main configuration panel (where you can set the cache duration). That one caches individual modules separately and can also be used for components. The other one is controlled by the system cache plugin, and doesn't seem to be configurable. I think it caches entire pages. Anyway, if you are trying to change modules based on browser detection, then the system cache plugin just isn't going to work properly, as it doesn't recognise that it should be giving out a different cache version for people on one browser and not on another.

So just turn it off, and clean out all the Joomla caches, and I think that most of the problems will disappear.

Maybe turning off the cache will also fix the problem with the IE Compatibility thing?

Anyway, if not, then in answer to your other questions:

1 - if you want MetaMod to not show a module, then just use a "return;" statement without a module id after it.

e.g. for the recipe I gave you last time:

$UA  = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$IE  = strstr($UA, 'MSIE') ? true : false;
if ($IE) return 16; // any version of IE
return; // any other browser, show nothing

2 - if you don't even want to show the MetaMod, then that's a bit trickier.
a - obviously, don't return a module id
b - turn off the title display of the MetaMod
c - try adding a module class suffix to the MetaMod - just a random one will do, e.g. "-metamod". This is often enough to cause your CSS to not recognise that the MetaMod is a module, so it won't get styled as a module
d - you may still have the problem that if the MetaMod was the *only* module in the module position, and if the MetaMod doesn't include any other module, then the template will often reserve space for the module position. This is very hard to get around unless you have exceptional PHP skills and can edit the template code to somehow get around it. HOWEVER - MetaMod Pro gets around this in a completely different way and is "install and forget", so that's definitely the easiest way to get around the issue.

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
4
User Info:
 
Total Users:
4378
Newest User:
miller2341
Members Online:
0
Guests Online:
115

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked