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.

 

Reciepe problem

Reciepe problem

Hi.
I hope, that i will find here some help for my problem! big_smile
The problem is the following:
I have here a weather module installed, and set up for 3 different cities: Satu Mare, Salaj(RO,31,"Salaj") and Cluj(RO,13,"Cluj"). That means 3 modules, each working.
The goal is, that by default the site shows me only the Satu Mare weather...
if the visitor is from the region of Salaj it shows only the Salaj weather, and when the visitor is from Cluj, it shows only the Cluj weather...
i have downloaded, and installed the GeoLiteCity.dat, and the metamod sees it. this is ok.
Now i am in the city Satu Mare...
here is the code what i have iserted:

Code:

return 48; //default, weather of Satu Mare

if ( $geoip->region - "Salaj" ) return 143; //weather of Salaj
if ( $geoip->region - "Cluj" ) return 144; //weather of Cluj

and this does not work...
it shows me only  the default weather. When i try to test is, i change the region code of salaj to my location, to see the changes...like this:

Code:

return 48; //default, weather of Satu Mare

if ( $geoip->region - "Satu Mare" ) return 143; //weather of Salaj
if ( $geoip->region - "Cluj" ) return 144; //weather of Cluj

but shows me only the satu mare, nothing happened...

i tried, to put the default weather in the quick module position, but then its always showing me the default (Satu Mare) and the Salaj weather...both, at the same time.

What i am doing wrong? What would be the rigth code for me in this case?

site: www.city-radio.ro
Joomla installation 1.5.15
mod metamod v2.2c

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

Re: Reciepe problem

Hi soosgyul,

first of all, nice web site!

There are a few things you need to change or check with your recipe.

1 - are you sure that $geoip->region actually gives you the right region in Romania? You can check this by using the following 1-line recipe in MetaMod, and checking the output, when in one of the cities or regions:

print_r($geoip);

That will print out all the information that GeoLiteCity is giving for that IP address. I hope that the region information will be correct, but I don't know if it's very accurate in Romania. I hope that it is, for your sake.

2 - don't use the Quick Module Position box (I think you know that).

3 - if you are going to use a "default" value, put that LAST in the list of rules. That's because PHP reads through the rules in order. If the default is first, then it will use that one, and will never check the other conditions.

4 - you have to use "==" to check for equality, not "-".

So, I think your rules should look like this:

Code:

if ( $geoip->region == "Salaj" ) return 143; //weather of Salaj

if ( $geoip->region == "Cluj" ) return 144; //weather of Cluj
return 48; //default, weather of Satu Mare

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

Re: Reciepe problem

thank you for your help!

it is almost working as I want it! Now the problem is, that the Salaj (RO,31,"Salaj"), and Cluj(RO,13,"Cluj") words are not recognized, just the two digit FIPS codes corresponding to the areas.
The problem with the codes its that for example the code "31" appears for another 30 cities and areas in different countries.
There is any way to specify in the code that i am looking for the 31 area code in Romania, and not elsewhere?

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

Re: Reciepe problem

Sure, I think this should do it:

if ( $geoip->country_code == 'RO' ) {
  if ( $geoip->region == "Salaj" ) return 143; //weather of Salaj
  if ( $geoip->region == "Cluj" ) return 144; //weather of Cluj
}
return 48; //default, weather of Satu Mare

It's obviously hard for me to test from New Zealand... but I think this should work smile
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
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Reciepe problem

thanks a lot...
i think now its working... now i am searching for some people in these cities to test it in live action big_smile
and this metamod... its amazing! thank you for it!
keep up the good work! big_smile

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

Board Info

Board Stats:
 
Total Topics:
1681
Total Polls:
6
Total Posts:
5912
Posts this week:
6
User Info:
 
Total Users:
11501
Newest User:
riley58745
Members Online:
0
Guests Online:
176

Online: 
There are no members online

Forum Legend:

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