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.

 

Can Chameleon actually be used as a template switcher?

Can Chameleon actually be used as a template switcher?

I'm looking to use it to allow the user to switch between 2 different templates - one is a high contrast version and the other is a standard colour one.

I was thinking of creating a separate menu containing normal and contrast links so chameleon would have something to work with code wise.

The only manual way of changing the template from a link that i know of is to use the ?template=hi-contrast code on a link, and this only changes the template for that page, once you navigate to another page it reverts back to the default template. Can this be done?

AlmondDesign
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Can Chameleon actually be used as a template switcher?

Okay i have been digging to see if there is any way to do this and found this youtube video http://www.youtube.com/watch?v=ku8q9rJQGR8 It seems to indicate that what i'm looking to do is possible. I followed the instructions and added a menu item which contained #contrast=yes so when it's clicked on it will add this string to the url.

I realise i'll need to add some kind of refresh on the link as well. This still didn't work as indicated in the video for some reason when i refresh the page, any ideas?

AlmondDesign
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Can Chameleon actually be used as a template switcher?

Yes, the page actually needs to refresh, so you can't simply use an anchor link to do this. This will present you with the problem that you may find it difficult to determine the "current" page in order to create a link to it. One way just using pure HTML is to make a mini form with a blank URL, and a hidden form field with a value in it. This should be guaranteed to go back to the same page that it came from, and it's easy to check for the form field value in Chameleon:

if (JRequest::getVar("myformfieldname") == "myvalue") return true;

... then that triggers the SUCCEED action in that rule. Use the code above *instead* of detecting the string in the URL.

A very basic form would be:

<form action="" method="post">
<input type="hidden" name="myformfieldname" value="myvalue" />
<input type="select" value="High contrast version">
</form>

Or with a clickable link:

<form action="" id="switcher" method="post">
<input type="hidden" name="myformfieldname" value="myvalue" />
<a href="javascript:void(1);" onclick="javascript:document.getElementById('switcher').submit()">High contrast version</a>
</form>


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

Re: Can Chameleon actually be used as a template switcher?

Thanks for your help on this. I'm just trying to work out how to implement it now. I've added the first piece of code to the main template and the form code i'm adding in a html module which will appear on all the pages. I have realised that i'll actually maybe need 2 forms, one to change to the appearance back again to the default template.

AlmondDesign
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Can Chameleon actually be used as a template switcher?

Yes, sounds like a good plan.

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:
4
User Info:
 
Total Users:
4378
Newest User:
miller2341
Members Online:
0
Guests Online:
124

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