Proposed changes to MailToUser Templates

Aug 2, 2010 at 8:47 PM
Edited Aug 3, 2010 at 6:09 PM

First let me thank you guys for providing some awesome code!  It makes it extremely easy to make tweaks when I have such good references to look at.  The main drawback that I saw with the MailToUsers template was that when you assign more than one person to the column, it displayed each user horizontally.  OOTB, you get the names listed vertically.  As such, I just added the ability to do so.  I hope the templates can be updated with my tweaks.  I had to change both templates for this to work, but as far as I can tell, my tweaks will not break existing code.

 

MailToUsers.xsl Usage:

<xsl:call-template name="MailtoUsers"> 
<xsl:with-param name="People" select="@AssignedTo"/> 
<xsl:with-param name="DisplayVertically" select="'True'"/>
</xsl:call-template>

 

MailToUsers.xsl Template:

 

<xsl:template name="MailtoUsers">
<xsl:param name="People" />
<xsl:param name="DisplayVertically" />
<xsl:choose>
<xsl:when test="contains($People, '&lt;tr&gt;')">
<!-- Get the next User -->
<xsl:call-template name="MailtoUser">
<xsl:with-param name="Person" select="$People" />
</xsl:call-template>
<!-- Add a separator if this isn't the last value -->
<xsl:if test="string-length(substring-after(substring-after($People, '&lt;tr&gt;'), '&lt;tr&gt;')) &gt; 0 ">
<xsl:choose>
<xsl:when test="$DisplayVertically = 'True'">
<br>
</br>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:call-template name="MailtoUsers">
<xsl:with-param name="People" select="substring-after($People, '&lt;/tr&gt;')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Get the last UserID -->
<xsl:call-template name="MailtoUser">
<xsl:with-param name="Person" select="$People" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:template>