By sharsant on
Hi all,
I am currently developing a site where on the landing page a user can kick a button where it will apply 1 of 2 themes until that button is clicked again. The theme must stay even if different pages are loaded.
I have been experimenting with the ThemeKey module (http://drupal.org/project/themekey) which is pretty amazing, but I cannot seem to define a set of rules which will allow this.
Any help would be great and thank you in advance. I am happy to explore other modules if need be but would rather stick to ThemeKey if it is achievable.
Comments
Here's how you can do it: 1)
Here's how you can do it:
1) Create a block for your theme switcher:
Then you declare the form to switch language:
Finally, you set the theme to be used in hook_custom_theme:
You can now use your block that has been created, that will add a button with which the user can change the theme. A random theme will be applied and will be used until the button is pressed again.
Note that default_theme_name, theme_1, and theme_2 must all be enabled for this to work.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Hi Jaypan, Thank you very
Hi Jaypan,
Thank you very much this will be very helpful!
One question though (and pardon the ignorance), but where am I meant to be placing this PHP code?
If I am correct I cannot place PHP directly into a block via Structure > Blocks > Add Block; So do I have to edit a php file directly?
Thank you again for all your help, I really appreciate it!
You need to put it in a
You need to put it in a custom module. Have a read on how to create Drupal 7 modules: http://drupal.org/node/361112
You'll need to change 'my_module' in all the code I showed you, to your module key (machine name). You'll understand what this means when you read about hooks.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Excellent, thank you very
Excellent, thank you very much. You have helped greatly!
One last question How can I
One last question
How can I change the button to an image that behaves like a button?
Again sorry for the ignorance on my behalf. This is really the first I have worked with PHP (although I did find your instructions to be very easy to follow...worked first time for me!)
Well, that's a different
Well, that's a different topic now isn't it :)
You can mark this one [solved] by editing the original post and adding [solved] to the title.
Glad it worked out for you!
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Fare enough ;) Think I have
Fare enough ;)
Think I have sorted it any way. Easier than I thought.
Once again, thank you very much for your help!