Copied to clipboard

Flag this post as spam?

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


  • Mikael Mørup 297 posts 326 karma points
    Jan 25, 2010 @ 14:28
    Mikael Mørup
    0

    Dynamic CSS

    I think there was a thread (maybee in the old forum) about this a long time ago but i can't seem to find it.

     

    Is it possible to "dynamically" choose og change the stylesheet used by a template ?

  • Thomas Vestergaard 52 posts 138 karma points
    Jan 25, 2010 @ 14:35
    Thomas Vestergaard
    0

    Hi Mikael

    What decides which stylesheet to use?

    /Thomas

  • dandrayne 1138 posts 2262 karma points
    Jan 25, 2010 @ 14:51
    dandrayne
    0

    umbraco.library:RegisterStyleSheetFile(String key, String url) might be useful, but you could also just use a content area placeholder in a template that inserts into the head of the master template?

    Dan

  • Mikael Mørup 297 posts 326 karma points
    Jan 25, 2010 @ 14:53
    Mikael Mørup
    0

    Sorry i was i bit unclear in my original post.

    Basically i wnat something that resembels "skinning" where the user can select a different layout / color scheme for a page /site.

    So the deciding factor is some kind of userinput that is not yet defined in detail.

     

  • Thomas Vestergaard 52 posts 138 karma points
    Jan 25, 2010 @ 14:58
    Thomas Vestergaard
    0

    I guess a simple macro that reads a GET parameter and puts it into the master template would do the trick.

    If you have a conChange event on a dropdown-box that reloads the page with a GET parameter that indicates which stylesheet has been chosen. Then the macro must read this GET parameter and write the value in the master template. If the GET parameter is not present, write a default stylesheet.

    Does this make sense?

    /Thomas

  • Thomas Vestergaard 52 posts 138 karma points
    Jan 25, 2010 @ 15:01
    Thomas Vestergaard
    0

    You probably have to save the selected stylesheet in a session or something to make sure the selected stylesheet stays active.

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jan 25, 2010 @ 15:37
    Nik Wahlberg
    1

    Couple of things here...

    1. If you're dealing with membership and personalization you will want a property of the member that stores which stylesheet to use
    2. I would tackle this using /Base so that I could set and change the stylesheet dynamically (using alternate title for the various themes http://www.w3.org/Style/Examples/007/alternatives). So, your Ajax call updates the member and then you use JS to switch/set the stylesheet (both onload and onchange). 
    Just my 2 cents....
    Cheers,
    Nik

  • Mikael Mørup 297 posts 326 karma points
    Jan 25, 2010 @ 22:57
    Mikael Mørup
    0

    Thanks for all your input. I'll dig into your suggestions and see what i can get from them.

  • Fergus Davidson 309 posts 588 karma points
    Jan 28, 2010 @ 14:24
    Fergus Davidson
    0

    now i am an umbraco newbie, so i have no clue what i am talking about.

    from a skinning point of view the suggestions above make sense, but i think it probably depends what you ae after. i am building my first [simple] site in umbraco and i spent a little wile looking at the dynamic CSS thing. My needs are slightly different, as all i want to do is to allow the CMS admin user to select different graphics to display in the background.

    for example select an image for the homepage which needs to be displayed as the background allowing for txt to go in front.

    as my needs are simple, i have gone with inline style tags. i know this is a compromise, and i will probably end up with writing a style block into the head of the page to control those few elements.

    if there is a better way of generating these within Umbraco i would also be intersested

     

Please Sign in or register to post replies

Write your reply to:

Draft