Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 954 karma points
    Jan 06, 2010 @ 00:40
    Tom
    0

    XSLT Macro Wrap Page In A Div

    Hi all,

    I want to generate a macro that will wrap some content in my template in a div.

    <div id="body">
        <form id="AdeptMasterForm" runat="server">

    <insert div from macro here with a class name based on current document type>
         <asp:ContentPlaceHolder ID="AdeptMasterContentPlaceHolder" runat="server"></asp:ContentPlaceHolder>

    <close div from macro here>
        </form>
       </div>

     

    or alternatively generate the body div above and append a class name using the macro..

    I was wondering how you actually do that where a macro can generate content before then after the template markup.. I was thinking of just rendering the opening tag using the macro but thought surely there must be a better way

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jan 06, 2010 @ 01:36
    Hendy Racher
    0

    Hi Tom,

    Is it just the class name of the div that needs to be generated ? ie. the closing </div> always exists ?

  • Tom 713 posts 954 karma points
    Jan 06, 2010 @ 02:22
    Tom
    0

    Hi Hendy

    Yeah it could be that if it's easier.. i was thinking of just using the macro to render the opening div tag but was wondering if there was an alternative..

    Cheers,

    Tom

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jan 06, 2010 @ 02:58
    Hendy Racher
    1

    Instead of using a macro, could also just make the <div runat="server"... and set the class attribute via the masterpage.

    How is the class name generated ? If it's a property of a node then the umbraco:item control with the insertTextBefore and insertTextAfter attributes could be used.

    HTH,

    Hendy

  • Tom 713 posts 954 karma points
    Jan 06, 2010 @ 04:25
    Tom
    0

    Hi Hendy..

    basically what i wanted to do was render

    <div class="SomeCategoryName">  where the current or ancestor has an instance of a certain document type

     

    ie category - correct doctype

          child category 1

          other child category 2

     

     

    some other category - not correct doc type

        invalid child category

     

     

    so for example "child category 1" and "other child category 2" and "category" would all get something like

    <div class="content categoryNodeProperty>

     

    and "some other category" & "invalid child category" would just get <div class="content">

  • slashslater 1 post 21 karma points
    Jun 10, 2010 @ 11:09
    slashslater
    0

    Hi Hendy, 

    Just like to thank you for your umbraco:item solution. Perfect for my requirement, of allowing a page to dictate what colour scheme to use.

    <umbraco:item field="colourScheme"  recursive='true' insertTextBefore="<div id='CS-" insertTextAfter="'>" runat="server"/>

    outputs perfectly

    <div id='CS-#'>

    can now change which colour scheme a page uses purely by adding a colourScheme field to Doc type.

    It's easy when you know how :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies