I'm trying to modify my menu XSLT to sort by a custom field, called SortOrder, which is defined for each textpage. As you can probably see, it's not much adapted from the original. (full listing below)
I'm using
<xsl:sort select="something"/>
as a basis. Sorting by known nodes, such as name, wors well, so I know that the XML is getting sorted OK.
The problem is how to reference the custom node. I've tried (without success):
<!-- update this variable on how deep your site map should be --> <xsl:variable name="maxLevelForSitemap" select="3"/> <xsl:variable name="level" select="1"/>
If your custom field is named "SortOrder" that's exactly what you should use (which is the last one you mention yourself) - however, convention is (and the UI will try to enforce this) to lowercase the first character for properties, so you should definitely check that the XML element is actually <SortOrder> and not <sortOrder>.
It's important not to include $currentPage here, because the XPath will be evaluated relative to the node being processed, so adding $currentPage will yield the same value for every node, thus not changing the sort order.
So Dirks example is what should actually work (you can omit the "./" though - doesn't change anything).
Is there an easy way of just getting out the XML at all - that way I can see firstly that the sort order field is included, and secondly, can make a better stab at the XPath!
*Ahem* - there's actually a package for that - look for "XMLDump"...
Alternatively, you can do <textarea><xsl:copy-of select="$currentPage/ancestor-or-self::root" /></textarea> somewhere, and you'll get a dump of the XML.
Menu - Sort by Custom Field
Hi there,
I'm trying to modify my menu XSLT to sort by a custom field, called SortOrder, which is defined for each textpage. As you can probably see, it's not much adapted from the original. (full listing below)
I'm using
as a basis. Sorting by known nodes, such as name, wors well, so I know that the XML is getting sorted OK.
The problem is how to reference the custom node. I've tried (without success):
I think I'm just missing some syntactically, but I'm not sure what, so any pointers would be much apprechiated.
Thanks for your time,
Tom
Full XML listing:
Can you try:
Hope this helps.
Regards,
/Dirk
Hi Tom,
If your custom field is named "SortOrder" that's exactly what you should use (which is the last one you mention yourself) - however, convention is (and the UI will try to enforce this) to lowercase the first character for properties, so you should definitely check that the XML element is actually <SortOrder> and not <sortOrder>.
It's important not to include $currentPage here, because the XPath will be evaluated relative to the node being processed, so adding $currentPage will yield the same value for every node, thus not changing the sort order.
So Dirks example is what should actually work (you can omit the "./" though - doesn't change anything).
/Chriztian
Hi there,
Neither of those things work I'm afraid.
Is there an easy way of just getting out the XML at all - that way I can see firstly that the sort order field is included, and secondly, can make a better stab at the XPath!
-tom
Hi Tom,
*Ahem* - there's actually a package for that - look for "XMLDump"...
Alternatively, you can do <textarea><xsl:copy-of select="$currentPage/ancestor-or-self::root" /></textarea> somewhere, and you'll get a dump of the XML.
/Chriztian
is working on a reply...