Umbraco Dynamic CSS - Multipe Sites, Same Template, Different CSS
Hi All,
So I have a project that I'm just about to start were I need some type of dynamic CSS created in content.
I'm creating kind of wordpress style platform where users can generate a new website within Umbraco by selecting a default template then working from that. I need to give the user the ability to add some custom CSS (shomehow).
There will be a number of websites sharing the same Umbraco templates. Since all the layout will be exactly the same for each website the Umbraco DocTypes / Templates will not change. The user will have the ability to override the CSS so they can set their desired colour scheme.
So I have been thinking more about the issue and I didn't come to a perfect solution but found a work around that should do the job.
I added a Repeatable TextString in my site settings.
I will store each line of custom CSS as a textstring
I then parse the repeatable TestString into a List
I then do a check to in the front-end razor script to see if there is any custom CSS. If so then generate a on-page style block/tag.
The only problems with this is that it limits the number of CSS rules I can add before it starts getting messy. Not too much of a problem for what I need. Also the CSS is on the page rather than stored nicely away in a file.
I thought that I might be able to get around this by checking if there any any CustomCSS and for the first time by code loads generate a custom CSS file on the fly using the .Net FileSystemObject. I would have to figure something out so we know if file has already been created or if the user makes edits to the CSS after the file has been created. Maybe have it as a separate DocType so I can track the updated date and compare it against the CSS file last updated date (a possible solution anyway).
I'm open to any smarter ideas if anyone is doing this a better way? This should be sufficient for what I need but I am definitely interested what other people are doing???
Umbraco Dynamic CSS - Multipe Sites, Same Template, Different CSS
Hi All,
So I have a project that I'm just about to start were I need some type of dynamic CSS created in content.
I'm creating kind of wordpress style platform where users can generate a new website within Umbraco by selecting a default template then working from that. I need to give the user the ability to add some custom CSS (shomehow).
There will be a number of websites sharing the same Umbraco templates. Since all the layout will be exactly the same for each website the Umbraco DocTypes / Templates will not change. The user will have the ability to override the CSS so they can set their desired colour scheme.
Any Ideas anyone?
Kind Regards
David
So I have been thinking more about the issue and I didn't come to a perfect solution but found a work around that should do the job.
I added a Repeatable TextString in my site settings.
I will store each line of custom CSS as a textstring
I then parse the repeatable TestString into a List
I then do a check to in the front-end razor script to see if there is any custom CSS. If so then generate a on-page style block/tag.
The only problems with this is that it limits the number of CSS rules I can add before it starts getting messy. Not too much of a problem for what I need. Also the CSS is on the page rather than stored nicely away in a file.
I thought that I might be able to get around this by checking if there any any CustomCSS and for the first time by code loads generate a custom CSS file on the fly using the .Net FileSystemObject. I would have to figure something out so we know if file has already been created or if the user makes edits to the CSS after the file has been created. Maybe have it as a separate DocType so I can track the updated date and compare it against the CSS file last updated date (a possible solution anyway).
I'm open to any smarter ideas if anyone is doing this a better way? This should be sufficient for what I need but I am definitely interested what other people are doing???
Thanks in advance
David
is working on a reply...