I am an uber umbraco noob. I am trying to create my first xslt/macro ever. The idea is to get a list of forum categories that link to the respective forum.
This will be a side column of my site that will always be there regardless of where the user is. I am failing miserably.
Is this possible with xslt? Could you plz give an example?
The following XSLT should do what you are looking for...
<!--Test to make sure some categories exist--> <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc and @level=1] /Forum//ForumCategory"> <!--Loop through the categories--> <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc and @level=1] /Forum//ForumCategory"> <!--Put your HTML markup here--> <p><a href="{umbraco.library:NiceUrl(.)}"><xsl:value-of select="./@nodeName" /></a></p> </xsl:for-each> <xsl:if>
Basically, the first bit of the select is getting the root node (the homepage) then it's searching for a node with the document type 'Forum' then any 'ForumCategory' document types that reside under that at any level (this is why there's a double slash - searches all children, not just direct decendents).
If you only want to get the main forum categories then you'll want to change the select to...
$currentPage/ancestor-or-self::*[@isDoc and @level=1] /Forum//ForumCategory[forumCategoryIsMainCategory=1]
System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value.
Any ideas? It didn't work to skip testing of the xslt.
get a simple Category listing
Hello nForum people,
I am an uber umbraco noob. I am trying to create my first xslt/macro ever. The idea is to get a list of forum categories that link to the respective forum.
This will be a side column of my site that will always be there regardless of where the user is. I am failing miserably.
Is this possible with xslt? Could you plz give an example?
Thank you.
Hi Thanos,
The following XSLT should do what you are looking for...
Basically, the first bit of the select is getting the root node (the homepage) then it's searching for a node with the document type 'Forum' then any 'ForumCategory' document types that reside under that at any level (this is why there's a double slash - searches all children, not just direct decendents).
If you only want to get the main forum categories then you'll want to change the select to...
Hope that helps.
Tom
Thank you for your reply Tom.
I have created the following xslt.
And I am getting an exception
System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value.
Any ideas? It didn't work to skip testing of the xslt.
is working on a reply...