Forum Discussion

keithkelly's avatar
6 months ago

Can We Truncate Subscription Email Post Body?

Problem:  

User reads an email subscription message body, which prevents them from checking out the actual thread.  Negatives:  metrics don't count, formatting (e.g., strikethroughs) don't show, etc. 

 

Desire:  Truncate message body w/ ellipsis.  

"A flux capacitor will help by eliminating the rotary sonar eff... [continue reading]"

 

Is this possible?

  • AndrewF's avatar
    AndrewF
    Khoros Oracle

    Hi Keith, as you discovered, the "?truncate" syntax is for Apache FreeMarker, while email templates utilize Apache Velocity 1.5. In the Marketo community thread, they referred to a couple of variables:

    Using utilities/tools like these would require that they have been placed on the context by the environment (the community application). Unfortunately Khoros does not provide access to these or other utilities.

    So you would need to find a way to do this yourself using conditional logic and the methods provided on the String itself. Here is the source code for those two utilities, which you could try to emulate:

    Broadly, any implementation would need to use the "length" method (to determine whether to truncate) and then conditionally use the "substring" method, plus some concatenation.

  • Emails are one area where Iā€™m REALLY looking forward to Aurora! 

  • Update:  I'm chickening out.  

    From what I've gathered in the past 30 mins....

    • This seems impossible.
    • ?truncate(16) doesn't work.  (rec'd below error when sending test email... then when triggering an actual email, the email was never sent/received.)
    • Email templates don't use FreeMarker; they use Apache Velocity.  While the documentation below the email editor says this, I didn't read it. 
    • Adobe's Marketo community gave me hope with .truncate: 

     

    $display.truncate($id,15,"")

     

    • But, it was in vain, as any combination of 

     

    ${display.truncate($notification.HTMLBody,15)}ā€‹

     

    or

     

    $display.truncate($notification.HTMLBody,15)ā€‹

     

    • just showed that exact string in the email, like
        
    • While perhaps I'm formatting it wrong, I'm losing hope and need to move on to other things.  

    If anybody knows Velocity and can verify if this is possible or not, please chime in!

     

    PS:  Here's the error I received when trying ?truncate(16) & clicking the "Send email to self" button.

     

  • Apologies forgot it was Velocity. Wonder how the Aurora emails are generated, hopefully something a bit more straightforward.

    We went down the route of not including the body text by default for similar reasons. It's easy enough for power users to enable it again. 

     

  • We tried this a few years back and eventually gave up because none of the functions we were expecting to be available to us would work.

    • keithkelly's avatar
      keithkelly
      Leader

      Interesting.  I was under the (probably false) impression that the email templates weren't actually Freemarker.  Whelp, maybe I should give it a try.... 

      We hired a Khoros partner to rebuild 1 of the emails, and they stated truncating wasn't a possibility.  I'll try and report back in a few mins.