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.

 

Browser type is: Array

Browser type is: Array

hi all my IE browser detection scripts stopped working so I updated to the current version which suggests a fix array issue but  I am still getting the same error.  I even uninstalled and reinstalled but when I run

echo "Browser type is: " . $core_genius->info("browser_type") . "<br  />";
if ($core_genius->check("browser_type = ie")) echo "It is IE!!!" . "<br  />";
echo "User agent is: " . $_SERVER['HTTP_USER_AGENT'] . "<br  />";
echo "MM_USER_AGENT: " . MM_USER_AGENT . "<br  />";

I get  Browser type is: Array

so none of my scripts for older browsers are working

jlefebvre
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Browser type is: Array

Hi jlefebvre,

you've uncovered a feature change that happened several versions ago. The change is that, as you can see, JomGenius now returns an array of browser types instead of a single string. The reason for this is that can be several valid browser types and it made sense to return them all rather than JomGenius having to decide which one was the "most correct". Examples of this include Safari variants that are also iPad or Android, for example. So it returns all relevant values in an array.

Where this causes problems is when you treat $core_genius->info("browser_type") as a string. In that case it assigns the word "Array" as you saw. In this case it's also difficult to compare this directly to check if it equals a certain string (direct comparison with =smile.

Therefore, the easiest way to check if the browser type equals a certain type is to use the JomGenius comparison function. Your example actually includes one of those:

if ($core_genius->check("browser_type = ie")) echo "It is IE!!!" . "<br  />";

In this case, even when the browser_type returns an array, JomGenius checks each element of that array, and if any one of them equals "ie" then the condition succeeds.

Did you notice that this condition actually worked?

Or if it didn't (and should have) then please let me know and I'll investigate further.

I expect that any code you were using that obtained with browser type and put it into a variable, then used an "if" on that variable would have started to fail with the MetaMod update.

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: Browser type is: Array

Hi Stephen,

When I use:

echo "Browser type is: " . $core_genius->info("browser_type") . "<br  />";
if ($core_genius->check("browser_type = ie")) echo "It is IE!!!" . "<br  />";
echo "User agent is: " . $_SERVER['HTTP_USER_AGENT'] . "<br  />";
echo "MM_USER_AGENT: " . MM_USER_AGENT . "<br  />";

I  get

Browser type is: Array
It is IE!!!
User agent is: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; Touch; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; LCJB)
MM_USER_AGENT: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; Touch; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; LCJB)

The  problem is  when I run the recipe to detect the browser version it does not detect it and serve the right content. 

I have been issuing browser warnings to display to incompatible browsers but now the warning shows for all IE versions instead of the ones targeted in the recipe. 

My recipe is:

// detect Internet Explorer v6 explicitly
if ( $core_genius->check( "browser = ie5" ) ) return 132;

// detect Internet Explorer v6 explicitly
if ( $core_genius->check( "browser = ie6" ) ) return 135;

// detect Internet Explorer v6 explicitly
if ( $core_genius->check( "browser = ie7" ) ) return 136;

// detect Internet Explorer v6 explicitly
if ( $core_genius->check( "browser = ie8" ) ) return 137;


You can verify this at our dev site https://references-etc.com/development/

jlefebvre
Beginner Modder
ranks
useravatar
Offline
2 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:
4385
Newest User:
hudson5478
Members Online:
1
Guests Online:
198

Online: 
hudson5478

Forum Legend:

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