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.

 

Passing Multiple Values into MetaMod Pro

Passing Multiple Values into MetaMod Pro

Hello there,

I'm trying to pass parameter values from the referring URL to MetaMod.

This simple redirect test works when using 2 different params:


URL: http://domain.com/page.html?site1=googl … ahoo"

$app = &JFactory::getApplication();
if (JRequest::getVar("site1")== "google"
and JRequest::getVar("site2")== "yahoo")
    $app->redirect("http://www.paypal.com/");


But does not work if using single parameter, such as:


URL: http://domain.com/page.html?site=google … ahoo"

$app = &JFactory::getApplication();
if (JRequest::getVar("site")== "google"
and JRequest::getVar("site")== "yahoo")
    $app->redirect("http://www.paypal.com/");


The goal is to pass multiple values for one parameter so MetaMod can display the appropriate modules according to the values (ie: if value1 and value4, then module7). My guess is I need an array, but I don't know how to implement.

Can you please help??? Thanks!!!

marclalosh
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: Passing Multiple Values into MetaMod Pro

Yes, using the same parameter more than once is generally not considered to be possible in PHP applications. I've done it in JSP apps, but you're right - in PHP you need to do it as an array (in which case you might as well do it as separate variables).

Anyway, you can do it like this:

domain.com/page.html?site[]=google&site[]=yahoo

Then you can get hold of the variables like this:

$site = JRequest::getVar("site");
if (is_array($site) and count($site) >= 2 and $site[0] == "google" and $site[1] == "yahoo") {
    $app->redirect("http://www.paypal.com/");
}

There are obviously lots of different ways that you can treat and check the array that comes out of this, but the important thing is that you pass the variables into the array with [] characters, and that you retrieve the array in a single JRequest::getVar call.

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

Re: Passing Multiple Values into MetaMod Pro

Stephen,

Perfect! Thank you so much for your help once again!

marclalosh
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: Passing Multiple Values into MetaMod Pro

Hi Stephen,

I'd like to take this a step further and use the values acquired from the URL to control FlexiTags used by AidaNews. In AidaNews, I can limit results by FlexiContent tag(s) by statically specifying tags in the parameters, but I want to do this dynamically (with URL variables).

So, if I get the variables "myTag1" and "myTag2" from:

$var = JRequest::getVar("var");
if (is_array($var) and count($var) >= 2 and $var[0] == "MyTag1" and $var[1] == "MyTag2") {
   
}

How would MetaMod tell an AidaNews module to limit results to the FlexiContent tags "MyTag1" and MyTag2"?

I'd be immensely grateful for any help!

marclalosh
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: Passing Multiple Values into MetaMod Pro

Hi marclalosh,

I'm not familiar with the AidaNews module so I need to check a few things.

The main thing is to find out whether the AidaNews module is able to filter by FlexiContent tags at all.

When you set up the AidaNews module in module manager, are there any fields/dropdowns etc that allow you to do this sort of filtering?

If so, MetaMod should be able to control these fields dynamically. If not, then MetaMod probably can't help.

Is AidaNews freely available? If so can you give a URL so I can take a look at it?

Cheers,
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: Passing Multiple Values into MetaMod Pro

Hi Stephen,

Thanks for the reply. I just discovered MetaMod's ability to control other modules parameters, which is exactly what I need. However, I'm not quite there yet. I'm trying to use this code from your site to change the "flexitags" parameter within an AidaNews module (id 155):

$changes->mod(155)
   ->setParam("flexitags", "Epic");
return 155;

However, when I use this, the module disappears altogether. If I remove the value and just use ("flexitags", ""), the module reappears, but obviously nothing is being changed.

BTW, I also tried "enable( false)" just to see if it would work, and it had no effect on the module.

If it makes any difference, the parameter setting in AidaNews is actually a multiselect box populated with FLEXIcontent tags (of which "Epic" is one) and not a text field.

What am I doing wrong?

marclalosh
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: Passing Multiple Values into MetaMod Pro

I just had a look at the source code for AiDaNews. I wasn't able to install and test this because it relies on FlexiAccess which is commercial.

However... it appears that the tags get stored under their ID numbers rather than the text of the tag itself. This is available in the "Tags" page in Flexicontent in the backend.

If you want to set the field to more than one, separate them with a "|", e.g.:

$changes->mod(155)
   ->setParam("flexitags", "1|2|3");
return 155;


I'm fairly confident this will work though can't test it.

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Total Posts Today:
2
User Info:
 
Total Users:
4367
Newest User:
dixon45621
Members Online:
2
Guests Online:
171


Forum Legend:

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