Copied to clipboard

Flag this post as spam?

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


  • Bruno Olsen 75 posts 316 karma points
    Jan 04, 2017 @ 10:33
    Bruno Olsen
    0

    xslt to razor help - simple listing grandchildren

    I'm trying to learn razor but keep running into stupid hurdles like this one ;) (I'm thinking this won't be the last post with that intro :D)

    Now, a simple listing of children isn't hard to do - Umbraco even supplies a sample snippet. But what if I want to do something like this:

    <xsl:for-each select="umbraco.library:GetXmlNodeById(xxxx)/*/* [@isDoc]">
        <xsl:if test="position() &lt; 6">
            <xsl:value-of select="@nodeName" />
        </xsl:if>
    </xsl:for-each>
    

    How would that look like in razor?

    Kind regards, Bruno

  • David Peck 690 posts 1896 karma points c-trib
    Jan 04, 2017 @ 14:48
    David Peck
    0

    Something like:

    @foreach(var grandchild in Umbraco.TypedContent(xxxx).Children().SelectMany( c => c.Children()).Take(6)){
        @grandchild.Name
    }
    
  • 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