Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » Can Chameleon actually be used as a...
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?
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?
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
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.
- Index
- » Chameleon / ChameleonLite
- » Chameleon
- » Can Chameleon actually be used as a...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7667
- Newest User:
- humble2601
- Members Online:
- 0
- Guests Online:
- 204
- 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