I have an Umbraco 4.7.1 website using the latest XSLT schema. I have installed the nForum package and I am trying to get the latest edited node that is of either one of two document types. I have the following XSLT:
<xsl:for-each select="descendant::* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:sort select="@updateDate" order="descending"/> <xsl:if test="self::ForumSection or self::ForumPost "> <xsl:value-of select="@nodeName"/> </xsl:if> </xsl:for-each>
This of course lists out all the nodes that are of document type ForumSection or ForumPost. I tried adding the following to only get one result but it then showed no results:
The reason position() isn't working for you is that it works on the "current nodeset" which, in a for-each statement, is the nodes returned from the XPath in the select attribute. If you include the name tests in the selection, it'll work:
Note also that you don't really need the [@isDoc] predicate when testing for specific Documents, unless you created properties with those names (which Umbraco tries hard to prevent you from by Pascal-casing those...)
It actually turned out that I didn't need this anymore (I was able to get the info I wanted another way), I did try and delete the post but thanks anyway because I am sure to need something like this in the future so it is good to know the correct way to do it.
You shouldn't try to delete the post anyway - this post has a very descriptive title and an answer that's easy to understand - perfect for anyone having that same problem tomorrow or next week.
Get last edited node of a certain document type
Hi All,
I have an Umbraco 4.7.1 website using the latest XSLT schema. I have installed the nForum package and I am trying to get the latest edited node that is of either one of two document types. I have the following XSLT:
This of course lists out all the nodes that are of document type ForumSection or ForumPost. I tried adding the following to only get one result but it then showed no results:
I then tried the following but this again gave me no results:
So I finally tried the following code but this just listed out all the results again like my first piece of code:
Can someone please point me in the right direction as to what I can do to just get one result?
Cheers
Tony
Hi Tony,
The reason position() isn't working for you is that it works on the "current nodeset" which, in a for-each statement, is the nodes returned from the XPath in the select attribute. If you include the name tests in the selection, it'll work:
Note also that you don't really need the [@isDoc] predicate when testing for specific Documents, unless you created properties with those names (which Umbraco tries hard to prevent you from by Pascal-casing those...)
/Chriztian
Thanks Chriztian,
It actually turned out that I didn't need this anymore (I was able to get the info I wanted another way), I did try and delete the post but thanks anyway because I am sure to need something like this in the future so it is good to know the correct way to do it.
Regards
Tony
Great to hear Tony.
You shouldn't try to delete the post anyway - this post has a very descriptive title and an answer that's easy to understand - perfect for anyone having that same problem tomorrow or next week.
/Chriztian
is working on a reply...