Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steve 472 posts 1216 karma points
    Dec 10, 2014 @ 20:16
    Steve
    0

    Sorting of Form Fields not Working Correctly

    I have a Contour form (Razor Macro) with conditional fields and I am using the XSLT transformed email workflow to display my field results in an email, but some of the fields are not displayed the the order they are on the form within the email. Here is my XSLT file that I am using; could someone take a look at it and see why some fields are not in the order that I placed them on the form?

    <xsl:param name="records"/>
    <xsl:template match="/">
    <table style="border-collapse:collapse;border:1px solid black;">
    <xsl:for-each select="$records//fields/child::*">
    <xsl:sort select="./@pageindex" order="ascending"/>
    <xsl:sort select="./@fieldsetindex" order="ascending"/>
    <xsl:sort select="./@sortorder" order="ascending"/>
    <tr style="border:1px solid black;">
    <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
    <strong>
    <xsl:value-of select="./caption"/>
    </strong>
    </td>
    <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
    <xsl:choose>
    <xsl:when test="contains(.//value, '/umbraco/plugins/umbracoContour/files/')">
    <a href="http://{umbraco.library:RequestServerVariables('SERVER_NAME')}{.//value}">
    <xsl:value-of select=".//value"/>
    </a>
    </xsl:when>
    <xsl:otherwise>
    <xsl:for-each select="./values/value">
    <xsl:if test="position() > 1">
    <br/>
    </xsl:if>
    <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.)"/>
    </xsl:for-each>
    </xsl:otherwise>
    </xsl:choose>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Dec 11, 2014 @ 01:57
    Chriztian Steinmeier
    0

    Hi Steve,

    This is very likely because the default sort data-type is "text", which means that "10", "11" & "12" etc. will come before "2".

    There's an easy fix — just add the data-type="number" attribute and they should move into place:

    <xsl:for-each select="$records//fields/*">
        <xsl:sort select="@pageindex" data-type="number" order="ascending"/>
        <xsl:sort select="@fieldsetindex" data-type="number" order="ascending"/>
        <xsl:sort select="@sortorder" data-type="number" order="ascending"/>
        <!-- ... -->
    </xsl:for-each>
    

    /Chriztian

  • Steve 472 posts 1216 karma points
    Dec 11, 2014 @ 14:22
    Steve
    0

    Thanks Chrizitian! That did the trick. Another quick formatting question though; Some of my form fields have entries using symbols like quotations, so the email comes back with &quot; instead of ". What would I do to display the quotes in the outputted email?

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Dec 11, 2014 @ 15:00
    Chriztian Steinmeier
    100

    Hi Steve,

    Great :)

    Ah, that's XSLT's automatic escaping doing its thing... you can disable that with an extra attribute on the <xsl:value-of /> instructions, e.g.:

    <xsl:value-of select="someValueToOutput" disable-output-escaping="yes" />
    

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft