Let user change stylesheet

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
niemi

Let user change stylesheet

Post by niemi »

Hello dear content managers  :-*

I have recently turned my site into CMSMS with success. The only thing I haven't suceeded in is letting the users change stylesheet via a piece of JavaScript. You can see what I'm talking about here: http://www.klagidag.dk/javascripts.php

Here the user have the options of using Metalic, Lazy Green and Pink Monster.

What I'm having problems with is not using the JavaScript. No, actually the JavaScript is working just fine, but if you look at the JavaScript you will see that it's necessary to specify where the stylesheets are located.

var ScreenCSS_1 = 'stylesheet.css';
var ScreenCSS_2 = 'stylesheetgreen.css';
var ScreenCSS_3 = 'stylesheetpink.css';

So that gives me some kind of a small problem right?  ;D
The stylesheets are stored in the database, so how the  ??? ??? ??? can I possibly tell my JavaScript where to look for the stylesheets?

Thanks in advance!
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Let user change stylesheet

Post by RonnyK »

Niemi,

one trick might be to make an external css of the 3, so that you can link them. Basically you could copy/paste and store them as a .css in the uploads-directory. Another possibility would be using StyleSheetSwitcher a module you an install from the dev.cmsmadesimple.org.

I would go for editing all in CMSMS and after changing one, copy it to an external file, that can be called.

I don't know another way, but others are more experienced in CMSMS and javascript.

Ronny
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Let user change stylesheet

Post by Dee »

I think this should work:
* create the stylesheets from the CMSMS Admin.
* create a template for each stylesheet and attach the stylesheet.
* find out the template ID from the URL of the edit template link
* use stylesheet.php?templateid=17 (example) in the javascript

Maybe the question mark has to be urlencoded to work in the JS, then it will be stylesheet.php%3Ftemplateid=17

Regards,
D
Zoorlat

Re: Let user change stylesheet

Post by Zoorlat »

Have you taken a look at the style sheet switcher module?
http://dev.cmsmadesimple.org/projects/styleswitcher

I have not tried it out myself yet, but I remember contemplating it for the same reasons you are mentioning. If you try it, pls tell what you find.
Locked

Return to “Layout and Design (CSS & HTML)”