Hi,
I have a set of Sitecore nodes:
<item>
<item>
<item />
</item>
<item /> <!-- (1) -->
<item />
</item>
<item>
<item />
<item />
</item>
I can obtain the path of these using a function sc:path(.), which returns something like '/item/item' for the point marked (1).
What I want to be able to do is group the item based on their path.
So my output would be something like:
<ul>
<li>in item
<ul>
...
</ul>
</li>
<li>in item/item
<ul>
...
</ul>
</li>
</ul>
I am playing with the preceding axes at the moment, as in the following code:
<xsl:for-each select="exsl:node-set($processedResult)/item">
<xsl:sort
select="substring-before(substring-after(sc:path(.),'/sitecore/media library/'),'.aspx')"
data-type="text"
order="ascending" />
<xsl:variable
name="path"
select="search:GetFriendlyPath('/sitecore/media library/',sc:path(.))" />
<!-- returns: item/item from /sitecore/media library/item/item/item.aspx -->
<xsl:variable name="lastPath">
<xsl:choose>
<xsl:when test="sc:path(preceding)">
<xsl:value-of
select="search:GetFriendlyPath('sitecore/media library',sc:path(preceding))" />
</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$path != $lastPath"> <!-- grouping test -->
<li>
<strong>in <xsl:value-of select="$path" /></strong>
</li>
</xsl:if>
<li>
<!-- render detail -->
</li>
</xsl:for-each>
... but sc:path(preceding) returns nothing. Hence my check doesn't work.
What am I doing wrong?