Created
February 5, 2013 18:03
-
-
Save uniquelau/4716347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" version="1.0" exclude-result-prefixes="umb"> | |
| <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> | |
| <xsl:key name="document-by-id" match="*[@isDoc]" use="@id"/> | |
| <xsl:template match="MultiNodePicker" mode="multipicker"> | |
| <!-- | |
| Make possible to override the key used to retrieve nodes | |
| --> | |
| <xsl:param name="key" select="'document-by-id'"/> | |
| <!-- | |
| This does the equivalent of calling the key() function for every <nodeId>, | |
| collecting the resulting documents into a node-set. | |
| Ideally we could just apply templates to that set, but unfortunately the nodes | |
| will be processed in document order... | |
| So, would be cool to just be able to do this: | |
| --> | |
| <!-- <xsl:apply-templates select="key($key, nodeId)" /> --> | |
| <!-- | |
| Workaround for the above - still only accessing the lookup table once | |
| --> | |
| <xsl:variable name="nodes" select="key($key, nodeId)"/> | |
| <xsl:for-each select="nodeId"> | |
| <!-- apply-templates, with mode=multipicker, so seperate templates can be used --> | |
| <!-- an example of this would be a product page, where related products are displayed in an aside --> | |
| <xsl:apply-templates select="$nodes[@id = current()]" mode="multipicker"/> | |
| </xsl:for-each> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Author
Nice update! Interestingly if I remove my 'multipicker' mode from that apply-templates, it crashes IIS horribly, some sort of weird internal memory allocation issue. No stack trace, etc.
I'm making a note of that here, so I don't lose another 2 hours trying to debug it! :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool - that's a neat idea, actually - at first I worried about potential endless loop (so would have suggested
mode="Widget"or similar to distinguish from this) but that won't happen unless you create a DocumentType called MultiNodePicker :-)BTW: There's a slightly improved (i.e. no for-each :-) version of the original here now: https://github.com/leekelleher/ucomponents-xslt/blob/master/uComponents.XsltTemplates/multipicker-helper.xslt
/Chriztian