|
|
Rank: Enthusiast
Joined: 1/30/2007 Posts: 22
|
Hi You'll have to excuse what I imagine is pretty bad xslt but I'm pretty new to this. I've created an A to Z index for a site and display that data in a different page for each letter. The xslt searches the field "sitemapMetadata", that each page contains, and if that value starts with the letter that is defined in the A-Z index page then it pulls back a link to that page. This all works fine(although I'm sure people could improve it) but what I'd like to do is be able to have more than one keyword in the "sitemapMetadata" field (perhaps seperated with e.g. a semicolon). So a page could appear more than once in the index e.g. a welcome page could appear under 'W' for Welcome but also 'H' for hello by putting in 'Hello;Welcome' in the sitemapMetadata field. If someone could point me in the right direction of what I would need to do to do this, that would be great. Thanks Gavin Code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<!--define variables--> <xsl:variable name="CapitalFirstLetter" select="/macro/CapitalFirstLetter"/> <xsl:variable name="LowercaseFirstLetter" select="/macro/LowercaseFirstLetter"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:for-each select="$currentPage/preceding::node"> <!--select all the sitemapMetadata information--> <xsl:sort select="current()/data[@alias='sitemapMetadata']/text()"/> <!-- When sitemapMetadata begins with the variable as defined in the actual page--> <xsl:choose> <xsl:when test="starts-with(data[@alias='sitemapMetadata'],$CapitalFirstLetter)"> <ul><li><a> <!--Make it a nice URL--> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/> </xsl:attribute> <xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> </a></li></ul> </xsl:when>
<!-- Now do it all again for the lowercase version of the letter--> <xsl:when test="starts-with(data[@alias='sitemapMetadata'],$LowercaseFirstLetter)"> <ul><li><a> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/> </xsl:attribute> <xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> </a></li></ul> </xsl:when> </xsl:choose> </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
Rank: Devotee
Joined: 8/31/2007 Posts: 50 Location: Utrecht NL
|
Code:<xsl:when test="contains(concat(';',data[@alias='sitemapMetadata']),concat(';',$CapitalFirstLetter))"> ...will work but does not solve the sorting.
|
|
Rank: Devotee
Joined: 8/31/2007 Posts: 50 Location: Utrecht NL
|
<xsl:when test="contains(concat(';',data[@alias='sitemapMetadata']),concat(';',$CapitalFirstLetter))">
...will work but does not solve the sorting.
|
|
Rank: Enthusiast
Joined: 1/30/2007 Posts: 22
|
Arjan den Boer wrote:
<xsl:when test="contains(concat(';',data[@alias='sitemapMetadata']),concat(';',$CapitalFirstLetter))">
...will work but does not solve the sorting.
thanks for the help. It certainly does solve the issue of putting the link in the two pages that are defined in the sitemapMetadata but I use Code:<xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> to display the link which unfortunately shows the sitemapMetadata field as 'Hello;Welcome' on both 'H' and 'W' pages rather than Hello on the 'H' page and Welcome on the 'W' page. So I thought that maybe it was possible to do something similar to that line, but being a bit new to this I haven't managed to get it right. Any ideas/pointers? Thanks Gavin
|
|
Rank: Enthusiast
Joined: 1/30/2007 Posts: 22
|
that would be Code:<xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" />
|
|
Rank: Enthusiast
Joined: 1/30/2007 Posts: 22
|
erm, sorry I seem to be incapable of showing that line of code... Code:<xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> or <xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> or <xsl:value-of select="current()/data[@alias='sitemapMetadata']/text()" /> sorry I don't know which way will work to display that line so might have some gobbledegook as well :blush:
|
|
|
Guest |