Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.


otooles
Beginner Modder
ranks
useravatar
User Info

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


Administrator has disabled public posting
otooles
Beginner Modder
ranks
useravatar
User Info

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


Administrator has disabled public posting
metamodguy
useravatar
User Info

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

Administrator has disabled public posting
otooles
Beginner Modder
ranks
useravatar
User Info

Re: How many queries will one metamod module run?

Hi Stephen,

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


Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 3076  Total Topics: 1195  Total Polls: 7  Total Posts: 4448  Posts this week: 18
User Info:   Newest User :  tao   Members Online: 2   Guests Online: 97
Online 
swivionForums7373
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked