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.

 

Country selection by using Metamod

Country selection by using Metamod

Hi,

I want to select country name on Home page of my developing site.

Country based menu is working fine for me.

How can i able to get country code from Metamod module to another page/module.

I tried to use $fromCountryId what we use on admin side.

And one more thing if we get Country Code form Metamod, after changing the country it will maintain the session?

Please help me. Thanks in advance.

Thanks,
Eswar.

eswar16
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Country selection by using Metamod

Hi Eswar,

If you want to use $fromCountryId in some other components or modules, then it may or may not work properly. It's a question of when the $fromCountryId is calculated. It gets calculated when the MetaMod is rendered, which is typically AFTER the main component on the page is rendered (so it is too late to pass it to the component). This may also be after some of the other modules are rendered, so there's no guarantee that the other modules can share the data.

Anyway, so if you can order the other modules so that the MetaMod is rendered first, then you could set a global variable, or put the value into the session, for you to be able to use it elsewhere.

e.g.

global $myCountry;
$myCountry = $fromCountryId;
// now we can use the global variable $myCountry in other modules. Hopefully.

You can do a similar thing to put it into a session.

Can you explain more about what you mean by "select country name on the home page of the site"?

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: Country selection by using Metamod

Hi,

Thanks for your valuable suggestion.

I am developing site based on country. Its open based on the Country IP using metamod.

If user wants to change the country,using country list drop down on home page (Country selection provided on home page), it should show country related pages. This is my requirement.

I am trying to develop using your suggestion. Only my concern is,when user changes country then how to set the changed country id to metamod , so that changed country pages will appear.

Thanks,
Eswar.

eswar16
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Country selection by using Metamod

Hi,

After selection country option, i need to set the country code/id on metamod. This my challenge. Please help me to set the value on metamod side.

Thanks,
Eswar

eswar16
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Country selection by using Metamod

Hi Eswar,

ok, I'm not sure if you are developing other components with PHP, or whether you don't know much PHP. Your 1st post suggests you might know quite a lot...

So, I would suggest that you code things so that if the site receives a certain parameter in the URL (that is provided by the dropdown for selecting country), that you set a session variable or cookie based on that. Then, in MetaMod you check for that session variable. If the session variable is not set, then use the GeoIP country.

e.g. like this in the MetaMod:

$override = JRequest::getInt('country');
if ($override == 1) $_SESSION['country_override'] = 'DE';
if ($override == 2) $_SESSION['country_override'] = 'ES';
if ($override == 3) $_SESSION['country_override'] = 'FR';
if ($override == 4) $_SESSION['country_override'] = 'BE';

if (isset($_SESSION['country_override'])) {
  // get it from the session, either set just now, or on a previous page
  $country = $_SESSION['country_override'];
} else {
  // get it from GeoIP
  $country = $fromCountryId;
}
// ... then test $country for whatever country code you're looking for


Then in your dropdown for selecting countries, the URLs would be:

example.com/?country=1 for Germany
example.com/?country=2 for Spain
example.com/?country=3 for France
example.com/?country=4 for Belgium


Does that sound like it will do the job for you?

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

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4388
Newest User:
wilmer7878
Members Online:
2
Guests Online:
160


Forum Legend:

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