- Posts: 103
- Thank you received: 2
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
- Topic Author
- Offline
- Premium Member
Less
More
7 years 1 month ago - 7 years 1 month ago #148249
by oleggorfinkel
Oleg G.
Can I conditionally include alternate blocks of HTML text in admin email? was created 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!
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.
- Deusdeorum
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 17
7 years 1 month ago #148251
by Deusdeorum
Replied by Deusdeorum on topic Can I conditionally include alternate blocks of HTML text in admin email?
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
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 103
- Thank you received: 2
7 years 1 month ago #148252
by oleggorfinkel
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.
Replied by oleggorfinkel on topic Can I conditionally include alternate blocks of HTML text in admin email?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
7 years 1 month ago #148253
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Can I conditionally include alternate blocks of HTML text in admin email?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
7 years 1 month ago #148255
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Can I conditionally include alternate blocks of HTML text in admin email?
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:
And something like this in the email template:
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13910
- Thank you received: 2548
7 years 1 month ago #148257
by DenisChenu
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.
Replied by DenisChenu on topic Can I conditionally include alternate blocks of HTML text in admin email?
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#
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
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 103
- Thank you received: 2
7 years 1 month ago - 7 years 1 month ago #148260
by oleggorfinkel
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.
Replied by oleggorfinkel on topic Can I conditionally include alternate blocks of HTML text in admin email?
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.