Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Aug 16, 2011 @ 22:08
    Carlos
    0

    Inline XSLT if statement

    Is there a way to write an XSLT if "true" statement inline in the template?

    If so that would be great and how would we do it.

    I want to check for true or false and tell the value to output a word like "repeat"

     

    Example for CSS in template

    background-repeat: inline XSLT goes here to output repeat if value is true if not output no-repeat if false.

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 16, 2011 @ 22:18
    Fuji Kusaka
    1

    Hi Carlos,

    Yes this is possible, you need to insert the Type (true/false) in your documentType. Then in your XSLT somthing like

    <xsl:if test="yourAlias !='1'"> background-repeat:</xs:if>

     

  • Carlos 338 posts 472 karma points
    Aug 16, 2011 @ 22:21
    Carlos
    0

    But can I do the inline XSLT?

    http://our.umbraco.org/wiki/reference/templates/umbracoitem-element/inline-xslt

    But using the inline XSLT true or false.

    The value to be "repeat" if true and "no-repeat" if false.

  • Carlos 338 posts 472 karma points
    Aug 16, 2011 @ 22:22
    Carlos
    0

    I guess I would make a macro, but I don't want to make another XSLT file just for a simple true/false

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 16, 2011 @ 22:26
    Tom Fulton
    0

    Hi Carlos,

    You can't do <xsl:if> statements inline on a template.  You can do this with Razor though as it supports inline macros.

    Another way to do logic inside your template using C# and nodeFactory is shown in this post:  http://our.umbraco.org/forum/templating/templates-and-document-types/15707-if-statement-on-masterpage?p=0#comment57895

    -Tom

  • Carlos 338 posts 472 karma points
    Aug 16, 2011 @ 22:28
    Carlos
    0

    Thanks all for the input. I will just make an XSLT file to check for the true or false and output my value that way through a macro.

     

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 16, 2011 @ 22:28
    Chriztian Steinmeier
    1

    Hi Carlos - you can use this little trick:

    <umbraco:Item field="pageID" xslt="substring('no-repeat|repeat', not($variable = 'value') * 10 + 1, 9)" runat="server" />

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft