4 Replies Latest reply on Dec 15, 2010 10:50 AM by corey.richey

    configuring email templates




      we've done some changes to our email templates after getting inspired by this discussion (thanks again so much). However, I stumbled across some difficulties, for example



      In the digest email template, the link to change your status just goes to the homepage. I'd like to have the link pointing to the user's profile like so


      Not doing that anymore? <a href="${jiveURL}/people/${user}">Log in and change it!


      But the above gives an error Anybody who can help me here?



      Or have some cool ideas with email templates?




        • Re: configuring email templates

          I configured the heck out of the email template for messages.


          I will paste my code below. I am working on doing the email template for the weekly email digest today and tommorow. So we will discover how to do it together. I will try that same line and see if i can get it to work. I think you have to make sure that ${user} is available in the template you are configuring.  Helpful documentation <a href="${jiveURL}/people/${user}">



          When you say gives an error? what do you mean? Do you hit validate and it gives an error? Do you save changes and it sends out the text version of the email (instead of the configured html version)? What version of jive are you in? I am in 4.0


          Here is the Thread Watch email i configured i took the code from another post on here and changed it a little. It displays an entire branch of the Thread rather than just the previous thread.


          <h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">

          Thread: ${contentSubject} <br />




          Posted by <#if contentAuthorURL?has_content><a href="${contentAuthorURL}">${contentAuthorName}</a><#else>${contentAuthorName}</#if>
          > <a href="${jiveURL}/message/${message.ID?c}#${message.ID?c}">View the Full Discussion</a> <br/>




          <#if includePostContentInEmail>
              <hr style="margin: 0px 0; border: none; background-color: #dadada; height: 1px;">
              ${contentBody} <br />
              <hr style="margin: 0px 0; border: none; background-color: #dadada; height: 1px;">


              <#assign messageroot=thread.getRootMessage()>
              <#assign seq = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","25","26","27","28","29","30"]>
              <#list seq as x>
                  <#if message.ID!=messageroot.ID>
                      <#assign message=message.getParentMessage()>
                      <br />
                      <b>Previous reply from
                      <#if message.anonymous>
                      </#if>: <br />
                      <hr style="margin: 0px 0; border: none; background-color: #dadada; height: 1px;">
                      ${message.body} <br />
                      <hr style="margin: 0px 0; border: none; background-color: #dadada; height: 1px;">
          </#if> <!-- includePostContentInEmail -->
          <div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">


              <p style="margin: 0;">Reply to this message by replying to this email -or- <a href="${contentURL}">go to the message on ${SkinUtils.getCommunityName()}</a></p>


              <p style="margin: 0;">Start a new discussion in <i>${containerName}</i> at <a href="${newContentURL}">${SkinUtils.getCommunityName()}</a></p>



            • Re: configuring email templates

              <#function getUserDisplayName(user)>
                  <#if (user?has_content && !user.anonymous)>
                      <#return SkinUtils.getDisplayName(user)?html />
                      <#return SkinUtils.getDisplayName(null) />


              <#macro userDisplayNameLink user='' rel='' plain=false>
                  <#assign userDisplayName = getUserDisplayName(user)/>
                  <#assign randomString = StringUtils.randomString(16) />
                  <#if plain>
                      <#if (!user.anonymous)><#assign userURL = JiveResourceResolver.getJiveObjectURL(user, true)>${userDisplayName} [${userURL}]<#else>${userDisplayName}</#if>
                  <#elseif (!user.anonymous)>
                      <#assign userURL = JiveResourceResolver.getJiveObjectURL(user, true)>
                      <a href="${userURL}"
                          <#if (rel?has_content)>
                          class="jiveTT-hover-user jive-username-link<#if !user.enabled> jive-user-disabled</#if>"



              This is how (i think) the user url is done. This code is taken from the default email digest. They made a little macro called userDisplayNameLink. and called this getUserDisplayName(user) which is from this javadoc


              method to check whether to display a user's full name or their username.


              so this returns their username.


              try this getUserDisplayName(user) instead of ${user} like this <a href="${jiveURL}/people/SkinUtils.getUserDisplayName(user)">


              or you might want to copy all of this code and use it. Because the conditional statements ensure that all cases are taken into consideration. Like if anonymous users are sent an email what will there display name be.


              P.S. I have never really coded much in Jive so everything i say should be taken with a grain of salt. I'm just guessing 99% of the time.

                • Re: configuring email templates

                  Hi Corey,


                  thanks for your replies!


                  Okay, we are on 4.5.3 but I think the templates are virtually identical. The code in your second reply matches the one in our digest template.


                  First, the error I see is "Error on line 362, column 133 in engagement.digest.email Expecting a string, date or number here, Expression user is instead a com.jivesoftware.community.util.MessageJiveObjectModel" when using <a href="${jiveURL}/people/${user}">. This error is shown using the Preview option. Saving the template works fine. Because of the error only the text version of the template is sent out.


                  Your suggestion doesn't err, but the resulting URL leaves the part SkinUtils.getUserDisplayName(user) unresolved in the URL which causes a "user not found" problem. I thought the syntax would needed changing to <a href="${jiveURL}/people/${SkinUtils.getUserDisplayName(user)}">. That syntaxt is correct (in 4.5.3). However, I believe that macro/function does not exist as part of SkinUtils while SkinUtils.getDisplayName(user) or getUserDisplayName(user) return the real name and not the userid as needed for the URL.


                  I'll do some more "testing" ...




                  Got the answer:

                  <a href="${JiveResourceResolver.getJiveObjectURL(user, true)}">

                  will provide you with the URL to a person's profile.


                  thank you for pointing me in the right direction


                  Here's the part where we are using it:



                  <#if (currentStatus?exists)>

                      Current status: "${SkinUtils.getDisplayName(user)} <span style="color:#666">${currentStatus}</span>"


                       <span style="font-size: 11px;">Not doing that anymore? <a href="${JiveResourceResolver.getJiveObjectURL(user, true)}">Log in and change it!</a></span>


                       <a href="${jiveURL}">Click here</a> and share what you are doing.