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.

 

How many queries will one metamod module run?

How many queries will one metamod module run?

Hi,

I've got metamod working and it's great. However when I try to run multiple queries it only ever returns the result of the first query.

Can metamod only run one query at a time?
If so, could I publish multipe metamods to a right column and have them all working?

Many thanks

otooles
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: How many queries will one metamod module run?

Sorry, I'll re-phrase this.

Is it only one "recipe" per module?
Can I display multiple "metamod" modules on a page, each with it's own recipe?

Thanks again

otooles
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: How many queries will one metamod module run?

Hi otooles,

the simple answer is "yes you can".

The more complex answer is "yes, but you have to recode the PHP a little".

The main point to remember is that whenever you use a "return" statement, execution of the PHP immediately ceases, and the module ids returned will determine the modules to be displayed.

Therefore if you want a series of "tests" or recipes, then you need to cumulatively add module ids to a list (technically, an "array"). Then you can return that array at the end of the rule and it will contain only the ids that you added to it earlier.

Here's an example of 2 rules, done the wrong way if you want the possibility of both module ids being returned:

if ( $option == "com_contact" ) return 55;
if ( $core_genius->check("browser = safari") ) return 66;

Do it this way instead:

$r = array(); // an empty array - always declare it first
if ( $option == "com_contact" ) $r[] = 55; // add "55" to the array in the Contact component
if ( $core_genius->check("browsertype = safari") ) $r[] = 66; // add "66" to the array if the browser is safari
return $r; // may be empty, or contain one or both of 55 and 66.

In case you're wondering, the syntax $r[] = value means "add the value value onto the end of the array".

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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: How many queries will one metamod module run?

Hi Stephen,

Thanks a million for the excellent support. That will solve my problem perfectly

otooles
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5910
Total Posts Today:
1
User Info:
 
Total Users:
10144
Newest User:
leonard5412396
Members Online:
2
Guests Online:
223


Forum Legend:

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