Good afternoon all.
is it possible to write velocity code directly against a module in an email template, or do I need to abstract it by referencing a script token in the template?
I'd like to build out a module that has the ability to comment itself out (often referenced here) without needing to add tokens in the email itself, and am curious as to best practice.
Cheers
Jo
It is possible to write a limited amount of VTL directly in a template (this is the reason that there are reserved words in templates). However, this is in no way supported, and I advise as strongly as possible that you not rely on it.
If you want to conditionally comment out a section, you should wrap it in Velocity {{my.token}}s.
Makes sense (and yes, I was already predicting problems with reserved characters).
Next silly question - can module variables be referenced in Velocity. E.g., I set the a variable called 'colour' to 'BLUE' on the module, and then depending on whether a lead has a checkbox 'loves_blue' checked leave the module on display, otherwise comment it out?
@SanfordWhiteman wrote:
Unfortunately not, those vars can't be used in VTL.
OK.. so imagine this.. I have three check boxes on the leads table... Loves_Blue, Loves_Red, Loves_Green.
I want to be able to create an email that displays a story on blue for lovers of blue, a story on red for lovers of red etc. If someone has multiple checkboxes checked, then they see multiple stories.
I don't marketers to have to be in the code, just ideally selecting the colour the story relates to.
Thoughts on how best to achieve that?
The marketer wouldn't need to edit any code.
You just put (at the template level) begin/end tokens with easily understood names:
The editable areas go in-between those tokens.
Each pair of tokens contains lightweight code to determine whether the stuff inside is output for each recipient, i.e. by matching a lead field against the color "blue".
Sanford,
Yep - there is that option. However, there are 28 variants.
My dream is that I could have a module where the user says 'this story relates to this interest (1 of 28)' and then use velocity to include or exclude.
e.g. Three copies of my story module in a Newletter email. If there were two stories with the interest A set, then a lead with an interest in A would see two stories. If there was a story with an interest of B set, then a lead with an interest of B would see one story. Obviously, if a lead had interests in A and B, then they'd see three stories.
I guess I'll just have to create a LOT of begin and end tokens 🙂
Cheers, and (as always) thanks for the help.
Jo
Yes. There isn't any way to tag a module using a mktoVariable in a way that Velocity can understand. You have to tag it by wrapping it in begin/end tokens. Although actually you don't need a special end token. It can be the same {{my.endStory}} for all of them.