Copied to clipboard

Flag this post as spam?

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


  • Fredrik Esseen 608 posts 904 karma points
    Aug 30, 2010 @ 16:34
    Fredrik Esseen
    0

    Simple For each in xslt with new schema

    Hi!

    Im trying to build a simple newlist and created a document type "Newslist" with types "News" as child.

    This is the xslt I use:

    <div class="NewsListPane">
    <xsl:for-each select="$currentPage/descendant::Newslist/node">
    <xsl:sort select="@createDate" order="descending"/>
    <xsl:if test="@nodeTypeAlias='News'" >
      <div class="NewsItem">
      <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a>
      </div>
    </xsl:if>
    </xsl:for-each>
    </div>

    This doesnt produce any news. What am I doing wrong?

  • Jamie Howarth 306 posts 773 karma points c-trib
    Aug 30, 2010 @ 17:23
    Jamie Howarth
    0

    Hey froad,

    You're using /node which no longer exists in the Umbraco 4.5 XML schema.

    You should be using:

    <div class="NewsListPane">
    <xsl:for-each select="$currentPage/*">
    <xsl:sort select="@createDate" order="descending"/>
    <xsl:if test="name()='News'" >
     
    <div class="NewsItem">
     
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName" /></a>
     
    </div>
    </xsl:if>
    </xsl:for-each>
    </div>

    Clarification: the * is a wildcard and your <xsl:if> block covers the rendering of your child News items.

    HTH,

    Benjamin

  • Hendrik Jan 71 posts 137 karma points
    Aug 30, 2010 @ 21:21
    Hendrik Jan
    0
    Its not really necessary but you should also use [@isDoc] 
    like:
    $currentPage/descendant::Newslist/* [@isDoc]
    but in your case you could even move to this:
    $currentPage/descendant::Newslist/News

Please Sign in or register to post replies

Write your reply to:

Draft