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.

 

change template with local hour as reference

change template with local hour as reference

Hi,

I want to change the template depending on the hour from the PC of the user, not from the SERVER.
Apparently the reference time is from the server, and I need to be the user hour... how can I solve this?

Thank You!

inaki13
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: change template with local hour as reference

Hi inaki13,

that's a really good question, but sadly it's not as easy as you might think to achieve.

Essentially because the time on the client is set on the client(!) it doesn't get automatically sent to the server, so Chameleon doesn't get a chance to find out about it.

You can of course use a snippet of JS on the page to get the local time zone and put it into a cookie where Chameleon would be able to pick it up and make decisions based on it. However logically this also means that you would not be able to use this on the FIRST page that a client requests, because at that point no JS has been run on the client in order to set the cookie... it's an annoying fact of the web request cycle.

There's a good discussion of getting time zones and/or time offsets (the number of minutes difference between GMT and the local time) with JS here:

http://stackoverflow.com/questions/13/d … -time-zone

Once you have it, then set a cookie with it and you can pick that up in PHP in Chameleon via the $_COOKIE[] array. You could then subtract it from the server's time and use that to switch the template.

Of course there are lots of ways of doing this; that's just one of them. Just bear in mind it won't work for the very 1st page that a client requests, though if you set the cookie with a long enough expiry date then it will work across sessions so if the user comes back tomorrow it will still remember what time zone they were in today.

Make sense?

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

Re: change template with local hour as reference

Many thanks! I will try to use that solution.

inaki13
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1675
Total Polls:
6
Total Posts:
5917
Posts this week:
6
User Info:
 
Total Users:
11577
Newest User:
owens65784
Members Online:
0
Guests Online:
175

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