Copied to clipboard

Flag this post as spam?

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


  • Probocop 51 posts 71 karma points
    Dec 21, 2010 @ 12:19
    Probocop
    0

    Create a class based on top level section?

    On the site I'm developing I'd like to put a class on the <body> that is the top level section.

    For example, If my URL structure is 'http://www.example.com/top-level/second-level/current-page' I'd like to have <body class="top-level">

    How would I go about doing so?

    Thanks!

  • Probocop 51 posts 71 karma points
    Dec 21, 2010 @ 12:22
    Probocop
    0

    Sorry, that link should of been

    http://www.google.com/top-level/second-level/current-page

    I tried to edit the original post but I got an XSLT error :)

  • Rich Green 2246 posts 4008 karma points
    Dec 21, 2010 @ 12:30
    Rich Green
    1

    Hey,

    You can use the following in your master template

      <body<asp:ContentPlaceHolder Id="bodyClass" runat="server"/>>

    Then in your child templates you can put:

    <asp:content ContentPlaceHolderId="bodyClassrunat="server"> class="top-level"</asp:content>

    Rich

  • Probocop 51 posts 71 karma points
    Dec 21, 2010 @ 12:33
    Probocop
    0

    Hi, Thanks for you response.

    I don't think that would work in my scenario, as I am using the same template for multiple sections on the website. For example the news, case studies etc. But I am after a small thing changing in one of the sections (hiding something with CSS). Is it possible to do such a thing dynamically with XSLT?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Dec 21, 2010 @ 12:35
    Chriztian Steinmeier
    0

    That's an evil hack Rich :-)

    I answered a similar question (body ID instead) here: http://our.umbraco.org/forum/developers/xslt/12017-Body-ID-selector-based-on-ancestor

    /Chriztian

  • Probocop 51 posts 71 karma points
    Dec 21, 2010 @ 12:46
    Probocop
    0

    HI Chriztian,

    That is what I was after, thank you very much!

    One question though, as my level 2 pages can be two words, is it possible to hyphenate them? And maybe also make it lowercase?

    Thanks!

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Dec 21, 2010 @ 12:57
    Chriztian Steinmeier
    0

    Hi Probocop,

    Sure thing - you could use the @urlName attribute instead of @nodeName, which is always lowercased and properly escaped.

    /Chriztian 

  • Probocop 51 posts 71 karma points
    Dec 21, 2010 @ 13:03
    Probocop
    0

    Perfect, thank you very much :-)

Please Sign in or register to post replies

Write your reply to:

Draft