Page 1 of 1

Let user change stylesheet

Posted: Fri Feb 16, 2007 4:50 pm
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!

Re: Let user change stylesheet

Posted: Fri Feb 16, 2007 5:42 pm
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

Re: Let user change stylesheet

Posted: Fri Feb 16, 2007 9:21 pm
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

Re: Let user change stylesheet

Posted: Fri Feb 16, 2007 9:33 pm
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.