Copied to clipboard

Flag this post as spam?

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


  • Garry Bain 149 posts 124 karma points
    Aug 04, 2009 @ 17:28
    Garry Bain
    0

    body id/class depending on parent page

    Hi,

    I want to give the <body> tag an id/class based on the parent page. For example my site map looks like this:

    Parent                                             Child pages

    About Us -> What we do | More about us | More about our associates

    The "About Us" page currently has the class <body id="about-us"> and this is taken from a field called bodyID that I created in the properties.

    Is there a way that I can pass this bodyID automatically to any child pages so they have this body class?

    Cheers, Garry.

  • dandrayne 1138 posts 2262 karma points
    Aug 04, 2009 @ 17:33
    dandrayne
    0

    If you use the page property directly in templates you can use

    recursive=true

    for it to apply to child pages

    eg

    <body class="<umbraco:Item field='bodyID' runat='server' recursive='true'>">

    (note the single quotes)

    Or in xslt you can just look for the parent(s)

    $currentPage/ancestor::node/data [@alias="bodyID"]

     

    Hope this helps,
    Dan

     

     

  • Garry Bain 149 posts 124 karma points
    Aug 04, 2009 @ 17:58
    Garry Bain
    0

    Brilliant - the recursive=true parameter worked.

    This is why I love umbraco - excellent and responsive user base - thanks very much!

Please Sign in or register to post replies

Write your reply to:

Draft