Listing all content that contains a specified 'tag'?
Hi, On the site I'm developling, I have a series of pages where the user can specify a Tag, and the page will display a list of content that contains that Tag. But I haven't managed to get the page displaying anything. Can anybody see anything wrong with the following XSLT?
The list of items can be narrowed further by clicking a tag which is displayed on the page.
'contentTags' is a field on all document types for entering the tags.
'tagToDisplay' is the field on the current document type for specifying the tag in which to display the content for.
<xsl:variable name="articles"> <xsl:choose> <xsl:when test="umbraco.library:Request('tag')"> <xsl:copy-of select="$currentPage/ancestor-or-self::* [@isDoc and string(umbracoNaviHide) != '1' and contains(contentTags,umbraco.library:Request('tag'))]" /> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$currentPage/ancestor-or-self::* [@isDoc and string(umbracoNaviHide) != '1' and contains(contentTags,$currentPage/tagToDisplay)]" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:for-each select="msxml:node-set($articles)/* [@isDoc]"> Show the page heading </xsl:for-each>
My content tree is as follows, and its the pages within the Policy section that I'm trying to list the content on.
You're only querying the ancestor axis for nodes, try to set a homePage variable once, and select pages from its descendant axis in stead - something like this:
Listing all content that contains a specified 'tag'?
Hi, On the site I'm developling, I have a series of pages where the user can specify a Tag, and the page will display a list of content that contains that Tag. But I haven't managed to get the page displaying anything. Can anybody see anything wrong with the following XSLT?
The list of items can be narrowed further by clicking a tag which is displayed on the page.
'contentTags' is a field on all document types for entering the tags.
'tagToDisplay' is the field on the current document type for specifying the tag in which to display the content for.
<xsl:variable name="articles">
<xsl:choose>
<xsl:when test="umbraco.library:Request('tag')">
<xsl:copy-of select="$currentPage/ancestor-or-self::* [@isDoc and string(umbracoNaviHide) != '1' and contains(contentTags,umbraco.library:Request('tag'))]" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$currentPage/ancestor-or-self::* [@isDoc and string(umbracoNaviHide) != '1' and contains(contentTags,$currentPage/tagToDisplay)]" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="msxml:node-set($articles)/* [@isDoc]">
Show the page heading
</xsl:for-each>
My content tree is as follows, and its the pages within the Policy section that I'm trying to list the content on.
Thanks!
Dave
Hi Dave,
You're only querying the ancestor axis for nodes, try to set a homePage variable once, and select pages from its descendant axis in stead - something like this:
/Chriztian
Hi Chriztian
That makes perfect sense, that you very much!
Dave
what if tag is a comma separated list of tags?? how would that work in this scenario? i am assuming split and a loop with a call to a template??
is working on a reply...