Copied to clipboard

Flag this post as spam?

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


  • Ryan Green 63 posts 83 karma points
    Jan 13, 2014 @ 20:30
    Ryan Green
    0

    Conditional Statement to include child nodes

    I have this conditional statement working, to not display content on a specific node. But I want to include all the children of that node as well.

          <% if (umbraco.NodeFactory.Node.GetCurrent().Id != 1234) { %>
      CONTENT TO NOT DISPLAY
        <% } %>
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 14, 2014 @ 22:48
    Dennis Aaen
    0

    Hi Ryan,

    If you're familiar with XSLT you can do it by adding an if statement in a XSLT file like this:

    <xsl:if test="$currentPage/@id !='1234' and $currentPage/../@id !='1234' ">
        CONTENT TO NOT DISPLAY
    </xsl:if>

    Make sure that you create an associated marco when you creates XSLT file, it will happen automatically if you don´t remove the checkmark. After you created XSLT and macro then place the macro in the template where the data should appar.

    It should also possible to do this in Razor, but since I don´t know which verson you´re using I don´t know if it possible for you to do it in Razor. To do it in Razor It´s require that you use at least version 4.7 if I remember right. From this version and forward the Razor engine become available.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft