Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 26, 2010 @ 15:33
    Sebastiaan Janssen
    0

    Send Multilingual xslt transformed email when Submitted?

    Unfortunately, the XSLT tranformation for Contour doesn't happen through the regular Umbraco methods, so it seems that I can't use dictionary items when sending an xslt transformed email. 

    Is there a way in which I can create some kind of an XSLT extension for this? Or am I stuck with having to create the same form for each language?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 26, 2010 @ 15:54
    Tim Geyssens
    0

    Checking the issue now

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 26, 2010 @ 16:18
    Tim Geyssens
    1

    Just tested it on a 4.5.1 install and it worked fine, here is my xslt

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:user="urn:my-scripts"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="xsl msxsl user umbraco.library">

    <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="DTD/xhtml1-strict.dtd"
    cdata-section-elements="script style"
    indent="yes"
    encoding="utf-8"/>

    <xsl:param name="records" />
    <xsl:param name="currentPage" />

    <xsl:template match="/">

    Test current page
    <xsl:value-of select="$currentPage/@id" />

    Test current date
    <xsl:value-of select="umbraco.library:CurrentDate()" />

    test dictionary

    <xsl:value-of select="umbraco.library:GetDictionaryItem('test')"/>

    <h3>Intro</h3>
    <p>
    Hello, this is a sample email using xslt to convert a record into a custom email
    </p>


    <h3>the fields</h3>
    <ul>
    <xsl:for-each select="$records//fields/child::*">
    <li>
    <h4>
    Caption: <xsl:value-of select="./caption"/>
    </h4>
    <p>
    <xsl:value-of select=".//value"/>
    </p>
    </li>
    </xsl:for-each>
    </ul>

    <h3>The actual xml</h3>
    <xsl:copy-of select="$records"/>

    </xsl:template>



    </xsl:stylesheet>

     

    It doesn't output the dictionary item value in preview mode but it does work fine when the form is on a page.

    What version of umbraco are you running ? Because I think there might have been a change to how the dictionary item is fetched in 4.5

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 26, 2010 @ 16:20
    Tim Geyssens
    1

    Sorry, in preview mode it also fetches the dictionary item value (based on the backoffice culture)

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 26, 2010 @ 16:26
    Tim Geyssens
    1

    Also if you used a dictionary item for your field caption, you can also get the value in the transformed mail

    So

      Caption: <xsl:value-of select="./caption"/>

    Becomes

      Caption: <xsl:value-of select="umbraco.library:GetDictionaryItem(substring(./caption,2))"/>
  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 26, 2010 @ 16:34
    Tim Geyssens
    1

    Just tested and it also works on 4.0.4.2

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 26, 2010 @ 16:48
    Sebastiaan Janssen
    0

    Excellent, it didn't work because of... Namespaces of course!

    This helped:

    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="xsl msxsl user umbraco.library">

    Thanks Tim!

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 10:51
    Sebastiaan Janssen
    0

    I'm running into two problems here:

    1. The subject of the e-mail does not fetch a dictionary item when I use the hash notation
    2. The default "Send email when Submitted" workflow item doesn't use the dictionary, so our site owner gets contact mails with a lot of hashtags

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 10:52
    Sebastiaan Janssen
    0

    Oh, one more: 

    One of my forms is not sending an XSLT transformed e-mail. The normal "Send email when Submitted" works fine, so it's not an SMTP problem. There is absolutely no error logging anywhere. How am I supposed to know what went wrong?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 27, 2010 @ 11:33
    Tim Geyssens
    1

    Hi Sebastiaan,

    You should get an entry in the log if the workflow fails to execute, are you sure the workflow settings are correct (sending to the correct email address) ?

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 11:39
    Sebastiaan Janssen
    0

    Ah, good catch! I have to change it to {#formLabelEmail} now since that label has changed. Would be good to have an error when the {} notation can't find that particular field.

    Are the other issues in your backlog now? :-)

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 27, 2010 @ 11:47
    Tim Geyssens
    1

    Ah didn't spot those before, will add those to our issue tracker and should be part of the next maintenance release

     

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 11:48
    Sebastiaan Janssen
    0

    Excellent! :-D

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 11:56
    Sebastiaan Janssen
    0

    Oh by the way, I just noticed that I'm using [@something] in the subject of one of the e-mails, I suppose it won't be difficult to make that work in dictionary items, but I just wanted to point that out so you won't forget. 

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 27, 2010 @ 11:57
    Tim Geyssens
    1

    Looks like an easy update, just fixed the issues,

    If you download the latest _update zip here (the one from today): http://nightly.umbraco.org/Umbraco%20Contour/1.1.3%20WIP/

    and simply replace your umbraco.forms.core.dll it should work

     

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 11:58
    Sebastiaan Janssen
    0

    Thanks! I'll check it out right now.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Aug 27, 2010 @ 12:25
    Sebastiaan Janssen
    0

    Works perfectly, I'm a very happy man right now, thanks again!!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Aug 27, 2010 @ 12:46
    Tim Geyssens
    0

    Great! Glad I could help ;)

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Sep 01, 2010 @ 16:53
    Sebastiaan Janssen
    0

    One more issue with this: in the normal "Send email when Submitted" workflow item, it doesn't send the translated prevalues for dropdowns, I just get the "#valueName", so it looks like that doesn't do a dictionary look-up.

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 01, 2010 @ 17:06
    Tim Geyssens
    1

    Should be fixed if you upgrade to the latest nightly of the work in progress version http://nightly.umbraco.org/Umbraco%20Contour/

    (you'll just need to replace the Umbraco.Forms.Core.dll)

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Sep 02, 2010 @ 12:04
    Sebastiaan Janssen
    0

    Works perfectly! 

    I think I've just tested everything that can be translated, glad to be a tester with such a responsive developer! ;-)

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Sep 02, 2010 @ 12:10
    Tim Geyssens
    0

    Great, thanks for your input ;)

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Sep 02, 2010 @ 12:25
    Sebastiaan Janssen
    0

    By the way, I can't remember where I your XSLT sample for sending transformed e-mails from, but the values also need to be translated when they start with a hash, I'm using tables but the idea is the same:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:user="urn:my-scripts"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="xsl msxsl user umbraco.library">
    
      <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
      doctype-system="DTD/xhtml1-strict.dtd"
      cdata-section-elements="script style"
      indent="yes"
      encoding="utf-8"/>
    
      <xsl:param name="records" />
    
      <xsl:template match="/">
    
        <table border="0" cellpadding="4" cellspacing="0">
          <xsl:for-each select="$records//fields/child::*">
            <tr align="left" valign="top">
              <td align="left" valign="top" style="font-family: arial; font-size: 12px;">
                <strong>
                  <xsl:value-of select="umbraco.library:GetDictionaryItem(substring(./caption,2))" disable-output-escaping="yes"/>
                </strong>
              </td>
              <td align="left" valign="top" style="font-family: arial; font-size: 12px;">
                <xsl:choose>
                  <xsl:when test="substring(.//value,1,1) = '#'">
                    <xsl:value-of select="umbraco.library:GetDictionaryItem(substring(.//value,2))"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select=".//value"/>
                  </xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
          </xsl:for-each>
        </table>
    
      </xsl:template>
    </xsl:stylesheet>

    The choose block is what I had to add to make transformed mails work properly.

    The only problem you might have here is that people might enter a # (maybe that's even required) as the first character in an input box. In that case you will need to explicitly add a condition on the test in the "when", to exclude that field by name.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Sep 02, 2010 @ 12:29
    Sebastiaan Janssen
    0

    Actually, you should do the same choose block for the field caption to make it generic! So it would become:

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:user="urn:my-scripts"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="xsl msxsl user umbraco.library">
    
      <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
      doctype-system="DTD/xhtml1-strict.dtd"
      cdata-section-elements="script style"
      indent="yes"
      encoding="utf-8"/>
    
      <xsl:param name="records" />
    
      <xsl:template match="/">
        <table border="0" cellpadding="4" cellspacing="0">
          <xsl:for-each select="$records//fields/child::*">
            <tr align="left" valign="top">
              <td align="left" valign="top" style="font-family: arial; font-size: 12px;">
                <strong>
                  <xsl:choose>
                    <xsl:when test="substring(./caption,1,1) = '#'">
                      <xsl:value-of select="umbraco.library:GetDictionaryItem(substring(./caption,2))" disable-output-escaping="yes"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="./caption" disable-output-escaping="yes"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </strong>
              </td>
              <td align="left" valign="top" style="font-family: arial; font-size: 12px;">
                <xsl:choose>
                  <xsl:when test="substring(.//value,1,1) = '#'">
                    <xsl:value-of select="umbraco.library:GetDictionaryItem(substring(.//value,2))"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select=".//value"/>
                  </xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
          </xsl:for-each>
        </table>
    
      </xsl:template>
    </xsl:stylesheet>
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies