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.

 

Timezone dependent modules

Timezone dependent modules

Hello!

My current task is to establish separate showing of two different mod_mainmenu modules dependent of visitor's timezone. In example, I have one mod_mainmenu for Irkutsk (UTC+9, ID 229) and one for Toronto (UTC-5, ID 230) and trying to set the 2 Metamod modules to show this modules separately.

I'm trying to use this constructions such as:

In first module:

if ( $timezone == "UTC+9" ) return 229;

In second module:

if ( $timezone == "UTC-5" ) return 230;

, but when I check my website, I see strange things. It shows Toronto module for  Irkutsk and when I try to load website via US web proxy (linear.ws), it shows Toronto too.

Here is debug output:

From Irkutsk:

 Spoiler Show Spoiler Hide Spoiler
 
MetaMod debug info:
Module ID: 228
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: Etc/GMT-9
$language: ru-ru
$language_code: ru
$language_region: ru
Country: RU
Country Name: Russian Federation
Including modules: Нет
MetaMod debug info:
Module ID: 232
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: Etc/GMT-9
$language: ru-ru
$language_code: ru
$language_region: ru
Country: RU
Country Name: Russian Federation
Including modules: 230
From USA:

 Spoiler Show Spoiler Hide Spoiler
 
MetaMod debug info:
Module ID: 228
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: Etc/GMT-9
$language: ru-ru
$language_code: ru
$language_region: ru
Country: US
Country Name: United States
Including modules: Нет
MetaMod debug info:
Module ID: 232
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: Etc/GMT-9
$language: ru-ru
$language_code: ru
$language_region: ru
Country: US
Country Name: United States
Including modules: 230
As you can see, the $timezone output is always UTC-9 (????). OK, maybe my browser transferring my real timezone through proxy, but why it shows UTC-9 for Irkutsk, when it must show UTC+9 ?

OK, maybe I was totally wrong thinking that Metamod supports timezone-dependent modules or did some syntax error... Please help me sad I have very poor php skills... would be really appreciated for any help.

-Joomla 1.5.26 latest
-Metamod 2.12 latest
-GeoIP Country (free or commercial) is enabled, .dat files is uploaded to the proper location
-Caching is disabled for metamod modules
-Metamod's Timezone setting is set to Joomla Default

pavelcarcass
Beginner Modder
ranks
useravatar
Offline
2 Posts
User info in posts
Administrator has disabled public posting

Re: Timezone dependent modules

Hi pavelcarcass,

the answer is fortunately easy but unfortunately bad news. The $timezone variable does not relate to the client. It only relates to the setup of the MetaMod, to what the timezone drop down is set to.

A web client does not normally send information about which time zone it is in, to the web server, as part of its web request.

The time zone may be able to be deduced if you use the GeoLiteCIty database, and want to work with the $geoip->longitude variable. It's not perfect, but I imagine that the longitude and the time zone generally are related. But it won't be perfect, and I don't know if every IP address will necessarily have a longitude associated with it.

From this page:

http://stackoverflow.com/questions/5584 … like-geona

I see this, for rough calculations:

"However, some very rough approximation can be calculated: 1 hour difference corresponds to 15 degrees longitude (360 / 24)."

Does that help?

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

Re: Timezone dependent modules

Hello metamodguy!
Thank you for your answer, now I have some food for thought.

I'd like to explain in general, what I have to do: the joomla-based website, which is authomatically determinate a content (especially, the modules) depending of visitor's region. And the more I investigate, the more I think that Joomla isn't good for such task sad

The best thing for me is $geoip->city (with GeoLite City database) , but it's WAY too inaccurate.

By the way, does the "GeoCity (commercial)" have any benefits in comparison with  free GeoLite City?

pavelcarcass
Beginner Modder
ranks
useravatar
Offline
2 Posts
User info in posts
Administrator has disabled public posting

Re: Timezone dependent modules

You can have a look at the comparisons with the different databases at www.maxmind.com. The commercial database is a little more accurate, but not that much (last time I looked). And it varies enormously between countries.

If the issue is about determining location, then it's really not Joomla that's the problem. The question is really about which underlying technologies you have available for determining location. You could look for alternative GeoIP databases, or alternatively look at JavaScript methods for requesting location data, which will often be highly accurate if the user is on a GPS-equipped mobile and gives you permission.

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

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Total Posts Today:
1
User Info:
 
Total Users:
5328
Newest User:
bwawsc
Members Online:
0
Guests Online:
77

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