Copied to clipboard

Flag this post as spam?

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


  • Lee 3 posts 33 karma points
    Aug 26, 2009 @ 15:37
    Lee
    0

    selecting a CSS file from a page

     

    Hi All,


    First of all, I just wanted to say what a great product and also if you could bear with me as im very new to umbraco and web design its self to be fair.


    Im building a site using umbraco 4 http://dev.abcnet.co.uk/connectivity/broadband.aspx adapting the CWS package.. most of the information is held in a master template and Insert general content via a two colum template that references the master template. However different pages will need to select a different style sheet. is there anyway to add the style sheet to be used via the two colum page template im using so it then inserts it in to the master template?


    I hope that makes sense... as mentioned before I am new to umbraco so if this can be done it would be appreciated if the answer could be done in a noob format :)


    Many thanks for any help!


    Lee

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 26, 2009 @ 15:45
    Warren Buckley
    100

    Yes lee this does make sense.

    In your top level masterpage add the following in your <head> section

    <asp:ContentPlaceHolder Id="headSection" runat="server"></asp:ContentPlaceHolder>

    Then in your two column master template add the following

    <asp:Content ContentPlaceHolderID="headerLinksContent" runat="server">
      <!-- Insert your CSS link here or JS or anything else you want shoved in the head that is unique to this template -->
    </asp:Content>
  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 26, 2009 @ 15:47
    Warren Buckley
    0

    Oops bad copy/paste error there on my part !

    The asp:content tag should read like this

    <asp:Content ContentPlaceHolderID="headSection" runat="server">
     
    <!-- Insert your CSS link here or JS or anything else you want shoved in the head that is unique to this template -->
    </asp:Content>
  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 26, 2009 @ 15:51
    Dirk De Grave
    0

    Lee, best way to handle this is:

    - to create a placeholder in the master template (in the head section, where the css declarations should go) -> to do so, use the insert content item placeholder dialog icon on the menu bar

    <asp:ContentPlaceHolder Id="StylesheetsPlaceholder" runat="server">
        <!-- Insert default "StylesheetsPlaceholder" markup here -->
    </asp:ContentPlaceHolder>

     

    - in you need to override the existing stylesheet from a master template, then you should place the master template's stylesheet in the placeholder, otherwise if the css file is to be included in all pages, do place it outside the placeholder tag, but still inside the head tag.

    <asp:ContentPlaceHolder Id="StylesheetsPlaceholder" runat="server">
    <link href="/css/master.css" rel="stylesheet" type="text/css" />
    </asp:ContentPlaceHolder>

    or

    <link href="/css/master.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder Id="StylesheetsPlaceholder" runat="server">
    </asp:ContentPlaceHolder>

     

    - in the 'child' template, add the placeholder you've defined on the master template (also insert dialog available from menu) and add the template's specific css file reference in there.

    <asp:Content ContentPlaceHolderId="StylesheetsPlaceholder" runat="server">
    <link href="/css/child.css" rel="stylesheet" type="text/css" />
    </asp:Content>
    


    Hope this helps.

     

    Regards,

    /Dirk

  • Lee 3 posts 33 karma points
    Aug 26, 2009 @ 16:17
    Lee
    0

    Wow that was quick... thankyou so much guys!!! warren as one on your blog a few days back... nice site :)

     

    Thankyou both, I will give it a shot later

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 26, 2009 @ 16:27
    Warren Buckley
    0

    Cheers Lee :)

Please Sign in or register to post replies

Write your reply to:

Draft