Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to provide different UI theme based on user who logged in. For that I have came up with following 2 options:

  • create separate files for all themes duplicating all the common css. This way I can easily do some login in scripting and get the required css file. But I end up having same css classes code in many different theme files. This is real pain when you have to change something common to all files.
  • make a common file and separate theme files containing only theme specific css. This way everytime I need to load 2 css files, one - common file by default and then load theme specific file to override default css classes.

Please help me to choose better option. If there is other simple and easy way to do it then please do let me know.

share|improve this question
    
Without detailed information difficult to say. But in general option two would be the better way. Maybe have a look at other themed solutions like jQuery UI ThemeRoller. –  thorsten müller Jul 17 at 9:21

1 Answer 1

Definitely go with option 2, it will be much easier to maintain. You could structure your CSS something like this:

css/
 |---default.css
 |---users/
       |----user1.css
       |----user2.css
       |----user3.css

I have a similar functionality implemented on my web site. Instead of giving each user a stylesheet, I have several predefined stylesheets that the user can switch between. I use JavaScript to change between stylesheets and a cookie to save their preferences across the site.

Another thing I did is in my equivalent of default.css, I have only the code that is the same across styles, and have an additional stylesheet that is applied by default (e.g. defaultuser.css).

share|improve this answer
    
Thanks for the reply. –  Harry Joy Jul 21 at 3:59
    
If no one else provides a better answer, be sure to accept mine. ;) –  Scott Weldon Jul 21 at 15:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.