0
votes

I need to say; I'm pretty green in xslt so, most likely, that's the main problem; nonetheless been on it for hours and can't get it. I want to fill a column on my main template with the 5 most recent newsitems. These newsitems should be shown regardless of the currentpage. I've tried this:

  <xsl:template match="/">
    <xsl:for-each select="umbraco.library:GetXmlNodeById(1075)/child::node">
        <p>
          <strong>
            <xsl:value-of select="header"/>
          </strong>
       </p>
    </xsl:for-each>
  </xsl:template>

Where, at the moment, 1075 is my News template. Ive tried it with just: GetXmlNodeById(1076)/node (where 1076) is my NewsItem template. I've tried it with the node-Id's from the content-tree, but no luck..

Anyone able to help me out here? Am stuck and I've searched high and low on Google, the forums and documentation, but I'm most likely missing something vital here. TIA!

P.S. Using Umbraco 4.5 BTW

1
I'm not familiar with Umbraco, but if you use just GetXmlNodeById(1076) without the /node, does that give you what you want?Owen S.
If I just use GetXmlNodeById(1076) I get a parser error.riffnl
What's the parser error you get and the line you entered? Add it to your question so we can try to get at the problem.Owen S.

1 Answers

2
votes

This should output current and child nodes.

<xsl:copy-of select="umbraco.library:GetXmlNodeById(1075)"/>

In Umbraco 4.5 the schema has changed, from /node[@nodeTypeAlias='News'] to /News [@isDoc]

http://blog.leekelleher.com/2010/04/02/working-with-xslt-using-new-xml-schema-in-umbraco-4-1/

So your xslt should look like

<xsl:template match="/">
    <ul>
        <xsl:for-each select="umbraco.library:GetXmlNodeById(1075)/News [@isDoc]">
            <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
       </xsl:for-each>
    </ul>
</xsl:template>