Copied to clipboard

Flag this post as spam?

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


  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 06:58
    Jonas Eriksson
    0

    create a un-closed un-escaped <body>-tag

    Hi! I would like to create and use a macro that inserts a unclosed body-tag with a class-attribute into my templates.

    <body class="conditional classes">

    I like to have a separate macro for this since several other macros as well as html are building up the rest of the templates.

    I can not get it to work. I tried to use cdata to produce my output, but that is escaped to &lt;body ... &gt;, and when I tried <xsl:text disable-output-escaping="yes"><![CDATA[ <body class="members"> ]]></xsl:text> I got nothing?

    Thanks!

  • Mikael Mørup 297 posts 326 karma points
    Sep 30, 2009 @ 08:41
    Mikael Mørup
    0

    I think something like:

         <body>    
               <xsl:attribute name="class">conditional classes</xsl:attribute>

     

    should do it.

     

    Mikael

     

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 09:15
    Jonas Eriksson
    0

    Hm, yes, but that won't work since the </body> is missing, and the xslt-parser will give me an error. Or am I missing something here?

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 09:16
    Jonas Eriksson
    0

    I just found out about inline xslt in template page fields, and I'm trying to use that approach.

  • Ron Brouwer 273 posts 768 karma points
    Sep 30, 2009 @ 09:18
    Ron Brouwer
    1

    u can use somthing like this <!DOCTYPE xsl:stylesheet [ <!ENTITY body "&lt;body class=&quot;YourClass&quot;&gt;"> ]>

    And then use &body;

    Ron

  • Mikael Mørup 297 posts 326 karma points
    Sep 30, 2009 @ 09:38
    Mikael Mørup
    0

    Yuo are right, the XSLT parser don't like missing closing tags.

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 09:38
    Jonas Eriksson
    0

    Thanks for that advice, but then I get an error from umbraco.macro.loadMacroXSLT

    Unexpected token '<' in the expression --><<-- body class="members">

    I read somewhere else that runat=server in the template tag causes this. But the macro should be inside an contentplaceholder so I need the runat=server afaik.

    And inline xslt in template page fields does not seem to work with <xsl:if> or <xsl:choose> should it?

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 11:01
    Jonas Eriksson
    0

    In my template I just would like to get a value from a xslt from within a tag:

    <body class="{call xslt to get class names}">

    The thing is that I use the same master template from several templates, many templates are used on both member and non-member pages. And we have different classes for the body on member and non-member pages. Phew... :-)

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 12:09
    Jonas Eriksson
    0

    I do not know what I missed but this works:

    <body class="<umbraco:Macro Alias='BodyClassMacro' runat='server'></umbraco:Macro>">

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 30, 2009 @ 12:12
    Jonas Eriksson
    0

    And my xslt looks like this:

    <xsl:if test="count($currentPage/ancestor-or-self::node[@id = $memberBranchStartNode])=1">memberclass</xsl:if>

    Problem solved, thanks for your input.

  • 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