Linking a MultiSelect LOOK-UP Column - with links to custom page.

Aug 19, 2013 at 9:23 PM
Hi all,
I used Marc's base code and modified it for use with multi-select lookup columns so that you could have each selected item link to a custom page that takes the item ID as a query string parameter. Blog post here:
http://deannaschneider.wordpress.com/2013/08/19/linking-a-multi-select-lookup-column-xslt-solution/

But, here's the code:
        <xsl:template name="MultiSelectDisplay">
        <xsl:param name="MultiSelectValue"/>
        <xsl:param name="MultiSelectDelimiter"/>
        <xsl:param name="MultiSelectSeparator"/>
        <xsl:param name="Link"/>
        <xsl:param name="ThisID" select="0" />
            <xsl:choose>
                <xsl:when test="contains($MultiSelectValue, $MultiSelectDelimiter)">    
                    <xsl:variable name="before" select="substring-before($MultiSelectValue, $MultiSelectDelimiter)"/>
                        <xsl:choose>
                            <!-- if we have a number, pass it back, but don't display anything -->
                            <xsl:when test= "string(number($before))!='NaN'">
                            <a>
                            <xsl:attribute name="href">
                            <xsl:value-of select="$Link"/><xsl:value-of select="$before"/>
                            </xsl:attribute>
                            <xsl:call-template name="MultiSelectDisplay">
                                <xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/>
                                <xsl:with-param name="MultiSelectDelimiter" select="$MultiSelectDelimiter"/>
                                <xsl:with-param name="MultiSelectSeparator" select="$MultiSelectSeparator"/>
                                <xsl:with-param name="Link" select="$Link"/>
                                <xsl:with-param name="ThisID" select="$before"/>
                            </xsl:call-template>
                            </a><br/>
                            </xsl:when>
                            <!--Otherwise, display and then pass back -->
                            <xsl:otherwise>
                                <xsl:value-of select="concat($before, $MultiSelectSeparator)" disable-output-escaping="yes"/>
                                <xsl:call-template name="MultiSelectDisplay">
                                    <xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/>
                                    <xsl:with-param name="MultiSelectDelimiter" select="$MultiSelectDelimiter"/>
                                    <xsl:with-param name="MultiSelectSeparator" select="$MultiSelectSeparator"/>
                                    <xsl:with-param name="Link" select="$Link"/>
                                </xsl:call-template>
                            </xsl:otherwise>
                        </xsl:choose>
                </xsl:when>
                <!-- Display the last item in the list -->
                <xsl:otherwise>
                    <xsl:value-of select="$MultiSelectValue"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
And here's how you call it:
<xsl:call-template name="MultiSelectDisplay"> 
                        <xsl:with-param name="MultiSelectValue" select="@Audience1."/>
                        <xsl:with-param name="MultiSelectDelimiter" select="';#'"/>
                        <xsl:with-param name="MultiSelectSeparator" select="'&lt;br /&gt;'"/>
                        <xsl:with-param name="Link">/tools/wnepresources/SitePages/Resources%20by%20Audience.aspx?AudienceID=</xsl:with-param>
                    </xsl:call-template>