Region selector pop-up

Region selector pop-up

Hi,

I'm new to metamod and have to be honest that I haven't even tried it yet.
However, before spending time trying to get something working that maybe never will, I'd like to ask if it's possible to achieve the following with MetaMod. (I'll buy the Pro version if it would be possible.. )

Here's the scenario I would like to achieve;

1. For any (new) user that comes to my site, I'd like him/her to choose 1 out of 4 available regions from a dropdown menu inside a pop-up.
2. Once the region is chosen, I'd like to show a module that is available only for this region. The others will be hidden. (Could be based on a keyword, or ID) (I'm envisioning to have 1 module for each region, so I want to show the one for the chosen region, hide the 3 others that are for the other regions.)

Hope that makes sense..

- Would it be possible to achieve this?
- I assume I somehow need to place a cookie, for the chosen region?
- Would it be very difficult to create this or rather straight forward?

Re: Region selector pop-up

Hi Mark,

thanks for getting in touch.

This is reasonably easy to set up, just requires a snippet of PHP for setting the cookies or session variables.

The basic plan is that you will have 4 "target modules", the modules for the 4 regions. These will be set up almost exactly as you would normally set up modules, except that you should set them up to NOT appear on any menu items.

Then you set up a MetaMod in the module position and on the pages where you want the Target Modules to appear. This will act as a container for whichever target modules needs to display. It also contains the logic that determines which one will appear.

In your case you also need to set up the trigger mechanism that will tell the MetaMod which choice the user has made. There are various ways you might do this. Here's one method:
- the dropdown menu inside the popup has links to 4 set URLs on your site. These could be to the same PAGE or to different pages. If the same page, then they would have a URL parameter that's different in each case.

Each of those URLs will pull up the same page, but MetaMod will be able to pick up the different region code and use this to trigger the module selection and/or session variables. The page can even be the front page if you like.

So the MetaMod has to be assigned to at least the "landing" page that your dropdown sends people to, so that the code in the MetaMod can do the detection etc.

// edit the mappings of region code to module id number as appropriate.
$modules = array("NY"=>101, "LA"=>102, "FL"=>103,"AL"=>104);
$region = $input->getVar("region");
// is the region mentioned in the URL, and one of our allowed ones?
if ($region != '' and @$modules[$region]) {
$_SESSION['regionselector'] = $region; // remember it in the session
return $modules[$region]; // display that module, here and now!
}
// Now check the session and see if a region was already set.
// If so, use it.
$region = @$_SESSION['regionselector']; // check the session
if ($region != '' and @$modules[$region]) { // see if it's non-null, and one we know about
return $modules[$region]; // display the appropriate module
}
// If we get through to here, the region was not in the URL, or was in the URL but invalid,
// or was not in the session. In any of those cases we don't display a target module.

Stephen BrandonMetaMod / Chameleon developerIf you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod