Welcome to the LimeSurvey Community Forum

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

Can I conditionally include alternate blocks of HTML text in admin email?

  • oleggorfinkel
  • oleggorfinkel's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 1 month ago - 7 years 1 month ago #148249 by oleggorfinkel
Depending on the user's answer to a particular question, I want to include one or another large-ish block of HTML text in the admin email. If it were only a single-line phrase, I could use a simple conditional expression: e.g. "Dear {if(USERTYPE=='student','Student','Teacher')}"; but in this case, what I need is to insert a multi-line block of text, which also includes an answer value. For example:

If the user is a student:

Dear {NAME},
Please read the following information for students:
xxxx
xxxx
xxxx

If the user is a teacher:

Dear {NAME},
Please read the following information for teachers:
yyyy
yyyy
yyyy

Any suggestions on how to do this?
Thanks!

Oleg G.
Last edit: 7 years 1 month ago by oleggorfinkel.
The topic has been locked.
More
7 years 1 month ago #148251 by Deusdeorum
What if you store your multi line block of text in the attributes of the token table? You can store pure HTML in there, so basically you can just put {TOKEN:attribute_1} in your confirmation mail.
The topic has been locked.
  • oleggorfinkel
  • oleggorfinkel's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 1 month ago #148252 by oleggorfinkel

Deusdeorum wrote: What if you store your multi line block of text in the attributes of the token table? You can store pure HTML in there, so basically you can just put {TOKEN:attribute_1} in your confirmation mail.


Trouble is, this particular survey is tokenless, because I need it to be accessible to the public without any pre-registration. Can I store the text in a hidden question? Is question text (rather than answer text) accessible via the Qcode?

Oleg G.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148253 by tpartner
Try placing the HTML in equation type questions and directly accessing those with Expression Manager in the email template.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148255 by tpartner
A further note...

In the equation question, you will need to remove all line-breaks and use htmlentities(). In the email template, use html_entity_decode().

manual.limesurvey.org/Expression_Manager#Access_to_Functions

So, for example, to load some HTML consisting of 2 paragraphs and giving the answer to a question code "Q1", something like this the equation question:
Code:
{htmlentities('<p>This is the first paragraph...</p><p>The answer to Question 1: '+Q1+'</p>')}

And something like this in the email template:
Code:
{html_entity_decode(equation1)}

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: oleggorfinkel
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148257 by DenisChenu
Hi,

I use another question text for complex system.

Example :

EmailText :
- Text_display question manual.limesurvey.org/Question_type_-_Text_display
- hidden if you want


And in may email i use directlt {EmailText.question}

You have an example here demonstration.sondages.pro/476956?lang=en#

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: oleggorfinkel
The topic has been locked.
  • oleggorfinkel
  • oleggorfinkel's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 1 month ago - 7 years 1 month ago #148260 by oleggorfinkel

DenisChenu wrote: EmailText :
- Text_display question manual.limesurvey.org/Question_type_-_Text_display
- hidden if you want

And in my email i use directly {EmailText.question}


Yep, that's exactly how I did it -- took me a couple of hours to sort it all out... :)
Except that initially, I used Long Text as the question type, because I thought I'd put the HTML in the answer part. But then I realized it's much easier to work with question text...

Thanks again, Denis, tpartner!

Oleg G.
Last edit: 7 years 1 month ago by oleggorfinkel.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose