TracCloudGuideProfilePrefsTwig: Difference between revisions

From Redrock Wiki

No edit summary
No edit summary
Line 20: Line 20:
<br><br>
<br><br>
Your {{Appointment.OnlineText}} appointment with {{Consultant.FirstLast}} at  
Your {{Appointment.OnlineText}} appointment with {{Consultant.FirstLast}} at  
{{Appointment.StartTime}} for {{Course.SubjectCourse}} has been scheduled.  
{{Appointment.StartTime}} for {{Course.SubjectCourse}} has been scheduled. If you have any  
If you have any questions prior to your appointment, feel free to reach out to {{Consultant.Email}}
questions prior to your appointment, feel free to reach out to {{Consultant.Email}}
<br><br>  
<br><br>  
Your appointment can be joined here: {{Appointment.OnlineURL}}
Your appointment can be joined here: {{Appointment.OnlineURL}}
Line 32: Line 32:
[[File:76y5rgeth4j75k.png|500px]]
[[File:76y5rgeth4j75k.png|500px]]
<hr>
<hr>
==if==
<i>if</i> statements will likely be the most commonly used Twig command for most use-cases. This allows you to write out statements such as <i>“if the student selected reason “Exam Help,” then include this piece of text.”</i> Or in the example below, <i>if the appointment is online, include text to specify this.</i>
<br><br>
In the statement, we’re using the same tags that are used for emails, but without the curly brackets.
<hr>
<nowiki>
Hello {{Student.First_Name}},
<br><br>
{% if Appointment.Online == "Online" %}
This is an online appointment.
{% endif %}
<br><br>
Please be ready for the appointment at the time you selected.
</nowiki>
<hr>
If the <i>if</i> statement is true, all text up to the endif line will be printed in the email. Since the appointment this student booked is online, the “This is an online appointment” text was included. Otherwise, it would jump straight to “Please be ready for the appointment…”
<br>
[[File:453j65ynh4g5rt.png|500px]]
<br><br>
We aren’t limited to just “equals” either. Similar examples with different logic can be found below.
<hr>
<nowiki>
{% if Course.Subject starts with "Chem" %}
this text is only included if our subject starts with “Chem”. This is case-sensitive.
{% endif %}
{% if Course.Subject ends with "101" %}
This text is only included if our subject ends with “101”
{% endif %}
{% if Appointment.Online != "Online" %}
This text is only included if the appointment is not online
{% endif %}
{% if Course.Subject == "Math" or Course.Subject == "Chem" %}
This text is only included if the subject is Math or Chem
{% endif %}
{% if (CalcMissedAppointments(Student.Sequence, Center.ProfileID) > 0) %}
You have {{CalcMissedAppointments(Student.Sequence, Center.ProfileID)}} missed
appointments since {{CalcMissedDate(Center.ProfileID)}}.
{% endif %}
</nowiki>
<hr>
|}
|}
{{DISPLAYTITLE:<span style="position: absolute; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">{{FULLPAGENAME}}</span>}}
{{DISPLAYTITLE:<span style="position: absolute; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">{{FULLPAGENAME}}</span>}}

Revision as of 12:37, 30 July 2021


Formatting Text in TracCloud with Twig and HTML

Many text boxes throughout TracCloud support Twig, this allows greater control in determining how emails are formatted and what data is included. HTML is also supported, allowing to you adjust the formatting of text. From font sizes, colors, and types, to embedding images and video.

Twig allows you to pull data from various TracCloud fields to be included in emails and texts via our tag system. We can also use Twig to apply logic to our text. Maybe we only want to include a block of text if the student selected a specific reason, or if a certain Recommendation was selected in a SAGE referral.

This chapter will be going over several Twig options available, however, this is not an in-depth guide. Twig isn’t exclusive to TracCloud, and there are many resources available online for more complex configurations if you’d like to go a step further. The point of this chapter is to give some brief examples and possible configuration ideas that you can build off of.

Most of the examples here will be formatted for an appointment confirmation email, but Twig can also be utilized in SAGE referral emails and in the upcoming appointments screen for students and consultants. The same concepts apply across the board.

Tags

Email tags can be used to pull data from various TracCloud fields to be included in emails and upcoming appointments. Many of the Twig examples in this chapter will be using these tags, whether they’re used as part of a Twig command or just offhandedly included in an unrelated part of the email. A list of tags can be found at the bottom of this chapter (and within the TracCloud menu), but for a basic primer on how these tags can be used in isolation, here’s an example of a confirmation email.


Hello,  {{Student.First_Name}}
<br><br>
Your {{Appointment.OnlineText}} appointment with {{Consultant.FirstLast}} at 
{{Appointment.StartTime}} for {{Course.SubjectCourse}} has been scheduled. If you have any 
questions prior to your appointment, feel free to reach out to {{Consultant.Email}}
<br><br> 
Your appointment can be joined here: {{Appointment.OnlineURL}}
<br><br>
Regards, {{Center.Name}}


When this email is sent, all the tags we included are replaced with the relevant information for this appointment.
76y5rgeth4j75k.png


if

if statements will likely be the most commonly used Twig command for most use-cases. This allows you to write out statements such as “if the student selected reason “Exam Help,” then include this piece of text.” Or in the example below, if the appointment is online, include text to specify this.

In the statement, we’re using the same tags that are used for emails, but without the curly brackets.


Hello {{Student.First_Name}},
<br><br>
{% if Appointment.Online == "Online" %}
This is an online appointment.
{% endif %}
<br><br>
Please be ready for the appointment at the time you selected.


If the if statement is true, all text up to the endif line will be printed in the email. Since the appointment this student booked is online, the “This is an online appointment” text was included. Otherwise, it would jump straight to “Please be ready for the appointment…”
453j65ynh4g5rt.png

We aren’t limited to just “equals” either. Similar examples with different logic can be found below.


{% if Course.Subject starts with "Chem" %}
this text is only included if our subject starts with “Chem”. This is case-sensitive. 
{% endif %}

{% if Course.Subject ends with "101" %}
This text is only included if our subject ends with “101”
{% endif %}

{% if Appointment.Online != "Online" %}
This text is only included if the appointment is not online
{% endif %}

{% if Course.Subject == "Math" or Course.Subject == "Chem" %}
This text is only included if the subject is Math or Chem
{% endif %}

{% if (CalcMissedAppointments(Student.Sequence, Center.ProfileID) > 0) %}
You have {{CalcMissedAppointments(Student.Sequence, Center.ProfileID)}} missed 
appointments since {{CalcMissedDate(Center.ProfileID)}}.
{% endif %}