Design and CSS styles
Version 4.x > Design and CSS styles > dynamic css View modes: 
User avatar
Member
Member
AP-Kentico - 7/10/2009 1:47:58 PM
   
dynamic css
Hi,

I want to add a dynamic stylesheet, via an aspx page and use all the dynamic styles.
but the sitemanager accepts only css files as the CMSPages_GetCSS class loads it dyamically.

How can I make this work?

Thanks,
Anil

User avatar
Member
Member
AP-Kentico - 7/10/2009 4:26:19 PM
   
RE:dynamic css
never mind,

I found a couple of ways to do this.

User avatar
Kentico Support
Kentico Support
kentico_radekm - 7/16/2009 8:30:33 AM
   
RE:dynamic css
Hello.

Could you please write here these ways, and share the solution also with anothers? Thank you.

Best Regards,
Radek Macalik

User avatar
Member
Member
AP-Kentico - 7/16/2009 9:04:47 AM
   
RE:dynamic css
This was required for custom webpart from where I could change the font size, font colors etc.

I could solve it by two ways:

1. Make new css files and store them in the kentico stylesheets.
The web part stores the users settings in the session/cookie.
change GetCss.aspx.cs to load the class from session/cokie.
Drawback: kentico updates will overwrite the GetCss.aspx.cs and you need several css files

2. Add this line as the first line in your css stylesheet in the kentico
@import url('~/CSS/DynamicStyle.aspx');
Add this file in the filesystem with code like as follows:
body
{
background-color: <%= GetFontBGColor() %> !important;
font-size: <%= GetFontSize() %> !important;
}
Here GetFontBGColor and GetFontSize are c# functions on that page retrieving user settings from session/cookie.

Hope this helps.


User avatar
Kentico Support
Kentico Support
kentico_radekm - 7/27/2009 9:06:46 AM
   
RE:dynamic css
Hello.

Thank you. I believe it can be useful also for another users.

Best Regards,
Radek Macalik