Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Email template conditional formatting

  • terryaulenbach
  • terryaulenbach's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 7 months ago #172512 by terryaulenbach
Email template conditional formatting was created by terryaulenbach
I'm trying to set up my email notification templates so that certain multiple choice responses will be included if they have been selected. I have a number of possible answers, but don't want blank lines to show if certain answers weren't selected. Here's what I've started with:

<tr>
<td style="vertical-align: top;"><strong>Topics to review:</strong></td>
<td
{INSERTANS:415993X2706X34550A1}<br />
{INSERTANS:415993X2706X34550A2}<br />
{INSERTANS:415993X2706X34550A3}<br />
{INSERTANS:415993X2706X34550A4}<br />
{INSERTANS:415993X2706X34550A5}<br />
{INSERTANS:415993X2706X34550A6}<br />
{INSERTANS:415993X2706X34550A7}<br />
{INSERTANS:415993X2706X34550A8}<br />
{INSERTANS:415993X2706X34550A9}</td>
</tr>

Is there some way to use an if statement so I don't have the extra <br /> tags?

Terry
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #172526 by tpartner
Replied by tpartner on topic Email template conditional formatting
I don't think you can do it with SGQA values but you could try something like this with Expression Manager variables:

Code:
{if(!is_empty(Q1_SQ001), 'Q1_SQ001: '+Q1_SQ001+'<br />', '')}    
{if(!is_empty(Q1_SQ002), 'Q1_SQ002: '+Q1_SQ002+'<br />', '')}    
{if(!is_empty(Q1_SQ003), 'Q1_SQ003: '+Q1_SQ003+'<br />', '')}    
{if(!is_empty(Q1_SQ004), 'Q1_SQ004: '+Q1_SQ004+'<br />', '')}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • terryaulenbach
  • terryaulenbach's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 7 months ago #172850 by terryaulenbach
Replied by terryaulenbach on topic Email template conditional formatting
Hey, Tony. This works... kind of. Any time any email templates are touched after the initial save, it stops working again and the code gets rearranged like so:

{if(!is_empty(WCHelp_A1), WCHelp_A1.question+'<br />
', '')} {if(!is_empty(WCHelp_A2), WCHelp_A2.question+'<br />
', '')} {if(!is_empty(WCHelp_A3), WCHelp_A3.question+'<br />
', '')} {if(!is_empty(WCHelp_A4), WCHelp_A4.question+'<br />
', '')} {if(!is_empty(WCHelp_A5), WCHelp_A5.question+'<br />
', '')} {if(!is_empty(WCHelp_A6), WCHelp_A6.question+'<br />
', '')} {if(!is_empty(WCHelp_A7), WCHelp_A7.question+'<br />
', '')} {if(!is_empty(WCHelp_A8), WCHelp_A8.question+'<br />
', '')} {if(!is_empty(WCHelp_A9), WCHelp_A9.question+'<br />
', '')} {if(!is_empty(WCHelp_other), 'Other: '+WCHelp_other.value+'<br />
', '')} {if(!is_empty(LibraryHelp_A1), LibraryHelp_A1.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A2), LibraryHelp_A2.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A3), LibraryHelp_A3.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A4), LibraryHelp_A4.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A5), LibraryHelp_A5.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A6), LibraryHelp_A6.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A7), LibraryHelp_A7.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A8), LibraryHelp_A8.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A9), LibraryHelp_A9.question+'<br />
', '')} {if(!is_empty(LibraryHelp_other), 'Other: '+LibraryHelp_other.value+'<br />
', '')}

This bit of the email ends up looking like this:

if( ! is_empty(WCHelp_A1), WCHelp_A1.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A2), WCHelp_A2.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A3), WCHelp_A3.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A4), WCHelp_A4.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A5), WCHelp_A5.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A6), WCHelp_A6.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A7), WCHelp_A7.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A8), WCHelp_A8.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A9), WCHelp_A9.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_other), 'Other: ' + WCHelp_other.value + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A1), LibraryHelp_A1.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A2), LibraryHelp_A2.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A3), LibraryHelp_A3.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A4), LibraryHelp_A4.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A5), LibraryHelp_A5.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A6), LibraryHelp_A6.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A7), LibraryHelp_A7.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A8), LibraryHelp_A8.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A9), LibraryHelp_A9.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_other), 'Other: ' + LibraryHelp_other.value + ' < br / > ', ' ' )
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #172854 by tpartner
Replied by tpartner on topic Email template conditional formatting
Don't use the HTML editor.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • terryaulenbach
  • terryaulenbach's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 7 months ago #172862 by terryaulenbach
Replied by terryaulenbach on topic Email template conditional formatting
OK, thanks. But my curiosity needs to be satisfied... what is it about the editor that breaks the code? Is it something that can be fixed in future updates?

Terry
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
5 years 7 months ago #172872 by LouisGac
Replied by LouisGac on topic Email template conditional formatting
In LS4 the text editor will be changed.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #172879 by tpartner
Replied by tpartner on topic Email template conditional formatting
Changed to what?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 7 months ago #172884 by jelo
Replied by jelo on topic Email template conditional formatting

LouisGac wrote: In LS4 the text editor will be changed.

A wiki roadmap page for LS 4 might help. ETA End of 2019. New HTML Editor. What else is already sealed?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • terryaulenbach
  • terryaulenbach's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 7 months ago #172971 by terryaulenbach
Replied by terryaulenbach on topic Email template conditional formatting
OK, so I did my editing without switching to HTML. Same problem. If I make changes to one template, save, make changes to the other template and save, the first template gets messed up. I suppose I can change both and then change, but I will always have to remember that any time I update ANYTHING in ANY of the email templates, I'll have to go back and re-enter the code for the 2 notification templates and save both at the same time to avoid sending messed up emails. Is there not a better solution?

Terry
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #172972 by tpartner
Replied by tpartner on topic Email template conditional formatting
Disable the HTML editor before opening the template editing screen. They are all loaded together, just in hidden tabs.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • terryaulenbach
  • terryaulenbach's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 7 months ago #172978 by terryaulenbach
Replied by terryaulenbach on topic Email template conditional formatting
Sorry, but I can't see where to disable it.

Terry
The topic has been locked.
  • holch
  • holch's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 7 months ago #172979 by holch
Replied by holch on topic Email template conditional formatting
manual.limesurvey.org/Global_settings#General

Default editor mode:

Default HTML editor mode: Sets the default mode for integrated HTML editor. The valid settings are:
inline (default): Inline replacement of fields by an HTML editor. Slow, but convenient and user-friendly
popup : Adds an icon that opens a popup window with the HTML editor. Faster, but the HTML code is displayed on the form
HTML source : No HTML editor used, just the plain html source


You will want to set the last option "HTML source". This sets it or the whole installation on all users.

You can also set this on your user preferences, but others might still run into the same problem. If you are the only one doing this kind of stuff, then this is probably the way to go:

manual.limesurvey.org/First_login_-_your...ces#HTML_editor_mode

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: tpartner
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose