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.

 

need some help with php condition

need some help with php condition

Hi,
I'm using virtuemart 2.6.6 on Joomla 2.5.20.
I've created 2 different menu displays (using swMenuPro) - one for use on mobile devices and one for use on laptops/PC.

I'd like to display them based on the following php condition but it doesn't work if I place it directly on the template's main page, so I'm checking if it could work in MetaModPro:

if(MobileDetector::isMobile() === true || MobileDetector::isTablet() === true) {
THEN DISPLAY MOD 107 ELSE DISPLAY MOD 109

How would I script that for all the pages, using MetaModPro? Are there additional special tags that I have to add to the php?

Also, do I add such conditions to an existing MetaMod module (I have one already in place for selectively displaying a gallery - do I add these conditions underneath it in the php box like standalone requests) or do I need to create another MM module just for the control of the display of these menus?

tap21
Junior Modder
ranks
useravatar
Offline
20 Posts
Administrator has disabled public posting

Re: need some help with php condition

Trying on my own, I set the menu assignment of one of the 2 menu options to "none" and then tried to call it up with this:

if(MobileDetector::isMobile() === false && MobileDetector::isTablet() === false) return 109;

but on my PC the menu doesn't appear. Is there something wrong with using that php command in metamodpro?

I use that line of conditional php successfully on the virtuemart pages, but I don't know if there's a problem using it here...

tap21
Junior Modder
ranks
useravatar
Offline
20 Posts
Administrator has disabled public posting

Re: need some help with php condition

Hi,

I wonder if the MobileDetector class has actually been loaded at the time that MetaMod is running?

You could try this code by itself in MetaMod to tell you:

if (class_exists('MobileDetector')) echo "found MobileDetector";
else echo "MobileDetector not loaded";

Now, if there's no output at all from that, then you don't have MetaMod set up right: it needs to be assigned to a valid module position, published, and assigned to one or more menu items (pages).

If you are seeing "MobileDetector not loaded" then the plugin (yagendoo Joomla! Mobile Detection?) isn't loaded: perhaps you need to order it 1st in the list of plugins, or set it to published, or somehow enable it?

If you see "found MobileDetector" then at least that part is working... you might need to test out the individual outputs from MobileDetector::isMobile()  and  MobileDetector::isTablet()  to see if these are giving you the expected results.

I hope that helps,
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
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10095
Newest User:
johnson58
Members Online:
0
Guests Online:
249

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