Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Armitage 508 posts 2078 karma points
    Jul 13, 2016 @ 15:20
    David Armitage
    0

    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

  • David Armitage 508 posts 2078 karma points
    Jul 13, 2016 @ 17:27
    David Armitage
    101

    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.

    1. I added a Repeatable TextString in my site settings. enter image description here

    2. I will store each line of custom CSS as a textstring enter image description here

    3. I then parse the repeatable TestString into a List

    4. 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. enter image description here

    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

Please Sign in or register to post replies

Write your reply to:

Draft