Copied to clipboard

Flag this post as spam?

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


  • Tristan 16 posts 36 karma points
    Mar 22, 2010 @ 21:52
    Tristan
    0

    Dynamic body id

    I have tried to search for this... but I'm sort of struggling to find the answer!

    Basically I want to put a dynamic variable in the template so that I can get a ID on the body tag that lets me give the page a specific style in CSS.

    I've figured out how to add a custom field to the properties tab for all pages calls "Cssclass", but I'm not too sure how to render it's contents on the frontend.

    If you could point me in the general direction of the answer that would be great!

     

    Tristan

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 22, 2010 @ 21:59
    Lee Kelleher
    1

    Hi Tristan, there's a package called Dynamic Body Tag in the projects section, that might be what you want?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 22, 2010 @ 22:00
    Jan Skovgaard
    1

    Hi Tristan

    Maybe this package is what you are looking for? http://our.umbraco.org/projects/dynamic-body-tag

    Otherwise you could fetch the value for every single node in your content tree by writing an XSLT macro and placing it in <body> like this

    <body <umbraco:Macro Alias="SetBodyId" runat="server"></umbraco:Macro>>

    Let me know if you need further assitance.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 22, 2010 @ 22:00
    Jan Skovgaard
    0

    I'm simply just typing too slow...I think I need to speed up! :-)

  • Tristan 16 posts 36 karma points
    Mar 22, 2010 @ 22:40
    Tristan
    0

    Thanks both, and thanks for the speedy response!

    I am curious though as to whether it's possible to actually just insert the contents of a custom property field in the template as well?

    So it would be something like <body class="cssclassproperty">

     

    thanks
    Tristan

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 22, 2010 @ 22:53
    Lee Kelleher
    2

    Yes, you can use the Umbraco:Item control to do this:

    <umbraco:Item field="cssclassproperty" insertTextBefore="&lt;body class=&quot;" insertTextAfter="&quot;&gt;" runat="server" />

    This would replace your <body> tag.

     

    @Jan, sorry - I seem to keep posting at the same time ... I'll trying to slow down! ;-)

    Cheers, Lee.

  • Tristan 16 posts 36 karma points
    Mar 23, 2010 @ 18:10
    Tristan
    0

    Thanks Lee, that's perfect!!

Please Sign in or register to post replies

Write your reply to:

Draft