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 by the 2-state button & time

Change template by the 2-state button & time

Hi,
I want to have on my joomla site two templates switching (day/night):

1. By time of viewing (eg. 22-7 night template). Made this succesfully setting a rule with custom PHP condition). Works fine, thank you ;]

2. I want to allow the user to switch template in any moment by 2-state button (one for day one for night template switch). With this my creativity come to the end and hope you can give me some hints... Should I use a menu in that rule? What menu item should be linked to? Maybe some other way...?

Great component BTW!
Cheers,

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

Re: Change template by the 2-state button & time

Hmmmm. I'm going to base these instructions on the video for "Switch template according to entry URL, then remember template for the rest of the session".
Admittedly that uses the Pro version, but it's easy to detect a particular part of the URL in PHP code:

if ( $core_genius->check("url endswith &day") ) return true;

and in another rule:

if ( $core_genius->check("url endswith &night") ) return true;


Let me think...

Rule 1: checks for "day" in URL. Succeeds if it's there. In Succeed action, sets cookie "A", sets the day template, and stops processing.

Rule 2: checks for "night" in URL. Succeeds if it's there. In Succeed action, sets cookie "B", sets the night template, and stops processing.

We only got this far if neither day nor night were in the URL. So now we check for the cookies:

Rule 3: check for cookie A. In Succeed action, sets the day template, and stops processing.

Rule 4: check for cookie B. In Succeed action, sets the day template, and stops processing.

We only got this far if day and night were not in the URL, and if no cookies had been set (because day or night had night been in the URL previously).

Rule 5: check for the time of day, and return true for daytime and false for night time.
In the succeed action, set the day template
In the failure action, set the night template.

That should take care of all the logic on that side.

The tricky thing you'll have to solve is how to make a link that always points to the current page, but with "&day" on the end of it. You might want to use MetaMod to construct that from the current URL and display it as a link... sorry it's late at night and I can't think!

It's easier if you just want to make a link that points to a particular page - then you can embed the exact URL including "&day" or "&night" at the end of it.
You could even make these menu items using the "External URL" type of menu item. Then you can even hide whichever one does not apply, as part of the succeed and fail actions above (i.e. if you are setting the day template, then hide the menu item that says "change to day template").

Hope that makes sense! I think you shoud be able to make it work. Again the most complex part is making a dynamic URL that points to the current page, wherever it is, except with "day" or "night" on the end.

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 by the 2-state button & time

Stephen
Thank you very much for help and suggestions.
We've finally worked out with Template Chooser extension (http://www.ultijoomla.com/downloads?fun … o&id=5) which actually base on the same logic you described.

Cheers,

JJ

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

Re: Change template by the 2-state button & time

Ok, glad you got it working.

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

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:
222

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