I am using a Repeatable Custom Content v2 control, displaying the results via XSLT. I need to know if there is a way to sort via one of the properties of the control. The property is a full name, so I would also need to sort by the last word, then the first word, then any second or third word.
Sort Reapeatable Custom Content
I am using a Repeatable Custom Content v2 control, displaying the results via XSLT. I need to know if there is a way to sort via one of the properties of the control. The property is a full name, so I would also need to sort by the last word, then the first word, then any second or third word.
Hi Connie,
A simple example: If your property is named "people", you could have something like this:
<people> <items> <item> <data alias="FullName">Jamie Jamieson</data> <data alias="ShoeSize">43</data> </item> <item> <data alias="FullName">Jamie Anderson Lee</data> <data alias="ShoeSize">45</data> </item> <item> <data alias="FullName">John James Anderson-Lee</data> <data alias="ShoeSize">41</data> </item> <item> <data alias="FullName">John Andersen</data> <data alias="ShoeSize">42</data> </item> <item> <data alias="FullName">John Peter Anderson</data> <data alias="ShoeSize">43</data> </item> </items> </people>Then this XSLT would take care of sorting by lastname then firstname:
<xsl:template match="/"> <xsl:apply-templates select="$currentPage/people" /> </xsl:template> <xsl:template match="people"> <xsl:apply-templates select="items/item"> <xsl:sort select="substring-after(data[@alias = 'FullName'], ' ')" data-type="text" order="ascending" /> <xsl:sort select="substring-before(data[@alias = 'FullName'], ' ')" data-type="text" order="ascending" /> </xsl:apply-templates> </xsl:template> <!-- Display template for a single item --> <xsl:template match="item"> <h2><xsl:value-of select="data[@alias = 'FullName']" /></h2> <p> Shoe size: <xsl:value-of select="data[@alias = 'ShoeSize']" /> </p> </xsl:template>Hopefully, you'll be able to complete the puzzle - otherwise, let us know!
/Chriztian
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.