More in this section

Forums / Developing with Sitefinity / Is it possible to modify the code that automatically loads theme CSS files?

Is it possible to modify the code that automatically loads theme CSS files?

6 posts, 1 answered
  1. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    08 Jul 2009
    Link to this post
    I want to add a second stylesheet to a theme, but it is going to be a dynamic stylesheet (dynamic.aspx), and since the extension is not .css Sitefinity does not pick it up. Is it possible to modify the code to allow .aspx files to be loaded in the same manner as .css files?

    Alternatively, is there some other method of accomplishing what I am trying to do?

    Thanks!
    anders
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    09 Jul 2009
    Link to this post
    I believe theming is handled by asp.net, not sitefinity directly, and as far as I know, asp.net only loads css files onto the page...

    just off the top of my head I guess you could handle the page_load and retrieve the Page.Theme property and search that folder for the aspx page, and, assuming you've set this aspx to respond as a css file, embed it onto the page header...

    but why reinvent the wheel? what is the reasoning behind building a dynamic sheet? I think a well-organized css structure would suit even complex needs. perhaps if you tell me more about what you're attempting to accomplish I could offer some further insight...

    I hope this was helpful!
  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Jul 2009
    Link to this post
    Hello,

    How about changing the page theme dynamically, in case you organize your CSS in theme level? You can also use the Sitefinity CssFileLink control and change the Css file from your code.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    10 Jul 2009
    Link to this post
    My reasoning behind wanting to use a dynamic stylesheet is for the following css:

    ul.multicolumnlist { 
        floatleft
        width: 50em; 
        margin: 0 0 15px 0; 
        padding: 0; 
        list-style-type:none
     
    li.multicolumnlistitem { 
        floatleft
        width: 10em; 
        margin: 0; 
        padding: 0; 

    If I put this in a dynamic stylesheet, I can tell it how many columns I want it to have. With this CSS, the whole list is 50em wide, and each item is 10em wide so I get up to 5 columns. If I can have dynamic control over this, I can change the width/number of columns on the fly. Although I suppose I could always just put a width style in the UL and LI elements and modify it that way.

    Anyway, thats my reasoning :P
  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    10 Jul 2009
    Link to this post
    in that case I would suggest you use the cssfilelinkcontrol as georgi suggested, you could point the file to the dynamic.aspx page so that you can pass it the necessary parameters (I'm assuming via query string?) so that it generates the correct file.

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sf" %> 
     
    <sf:CssFileLink ID="CssFileLink1" FileName="/css/dynamic.aspx?columns=5" Media="screen" runat="server" /> 
    Answered
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Jul 2009
    Link to this post
    Hello SelArom,

    Thanks for extending my point of view. Much appreciated! :)

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
6 posts, 1 answered