If we were to implement velocity scripts for these items, it looks like we would have to create the different layouts for each section to account for inserting each of the velocity scripts.
You mean if you were going to emit all the HTML from Velocity? Yes, that would require a... let's say, recontemplation of the email structure.
But just emitting the comments from Velocity doesn't require you to change anything.
I'd probably do this, but yep, that's the idea:
#set( $displayForSegments = ["SegmentName1","SegmentName2"] )
#if( $displayForSegments.contains($lead.Relevant_Segmentation_Field) )
<!--
#end
Remember that formal notation is discouraged anywhere but in output, because it breaks method chaining.
#if( ${lead.Relevant_Segmentation_Field}.isEmpty() ) ## syntax error
vs.
#if( $lead.Relevant_Segmentation_Field.isEmpty() ) ## good
Sanford Whiteman - So I have been working on implementing this, and for some reason, the token is not commenting out the section that I am trying to hide.
#if (${lead.Segmentation_CompanyUpdateDRLTitle_1013} == "Default")
<!--
#else
#end
Since I am viewing the preview as a person that is part of the Default value of that segment, I am wondering if I am doing something that is causing a syntax error. Below is where the token is used in the email.
<!-- Company Update Title Module Begin-->
{{my.Company-Update-Section-Begin}}
<table class="mktoModule" mktoActive="true" mktoAddByDefault="true" id="Company-Update-Header" style=" -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: collapse;" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" mktoname="Company Update - Title">
<tr>
I have already removed all comments that were in the template that could possibly interfere with the implementation of this. Any thoughts?
Do you have the closing comment as well?
Yes, I do. If I didn’t have —> to close the comment, it would hide everything up to wherever the next comment is. Unfortunately that is not the case here.
I'm not clear on what isn't happening. You need 2 tokens but I'm only seeing one; if you have 2, and they're both being output, then they will comment out whatever's in-between.
I also notice you're not using the code I recommended. ${formal} notation isn't for use in Velocity #if conditions, use $simple. Use formal only for output, and even then only when proven necessary, as it disrupts method chaining.
I do have the ending comment in a token as well. So you would take out the { }? I will test tomorrow with that.
So here are my two tokens, but it doesn't seem to be working.
{{my.Company-Update-Section-Begin}}
#if ( $lead.Segmentation_CompanyUpdateDRLTitle_1013 == 'Default')
<!--
#end
{{my.Company-Update-Section-End}}
#if ($lead.Segmentation_CompanyUpdateDRLTitle_1013 == 'Default')
-->
#else
#end
Below is how the HTML looks (with the tables minimized). There are no comments within all of those individual modules.
First, how are you testing? You need to use Preview-by-List or send a real email (not sample) to test lead-senstive Velocity.
Second, if you're implying the #else condition is being met instead of the #if, can you put some debugging text in there to prove that conclusively? And also output $lead.Segmentation_CompanyUpdateDRLTitle_1013 to aid in debugging.
I am testing using the preview-by-person. The issue that I am seeing currently is the following (and sorry if I am not explaining this right).
So I have the My.Tokens inserted into the areas of the template where they should be (between the respective modules necessary). When I create the email draft in the program where the tokens are, I am looking into the code of the email template, and it looks like all of the tokens within the <body> </body> have disappeared.
I think this could be what is causing the issue here.