if, elif and other variations

Examples of more extensive uses of If logic see If Logic - Create customised emails

To show a students first name or preferred name

{% if profile.preferred_name %} {{ profile.preferred_name }} {% else %} {{ profile.first_name }} {% endif %}

To show first name and preferred name if there is one

{{ profile.first_name }} {% if profile.preferred_name %} {{ profile.preferred_name }}) {% endif %} {{ profile.last_name }}

To select a specific attendance type (note the attendance type must match the name in settings>school details>Attendance Types & Fee

{% if profile.attendance_type == "Day Student" %} add information here{% endif %}

{% if profile.attendance_type == "Boarder" %} add information here{% endif %}

To select all year groups greater than a specified year (the Grade/Year Value is shown in Grade of Entry Settings)

{% if profile.entry_grade|gt:6 %} add information here {% endif %}

To select all year groups less than specified

{% if profile.entry_grade|lt:7 %} add information here {% endif %}

To select a specific year group

{% if profile.entry_grade == 5 %} add information here {% endif %}

To select a specific set of year groups with different responses based on year of application

{% if profile.entry_grade|gt:-1 and profile.entry_grade|lt:3 %} For {{ campus.name }} {{ profile.entry_grade_label }} entry, (from Kindy to year 2) add information here

{% elif profile.entry_grade|gt:2 and profile.entry_grade|lt:7 %} For {{ profile.entry_grade_label }}, {{ profile.entry_year }} entry, (from Year 3 to Year 6) add information here

{% elif profile.entry_grade|gt:6 and profile.entry_grade|lt:9 %} For {{ profile.entry_grade_label }}, {{ profile.entry_year }} entry, (Year 7 to Year 9) add information here{% else %}

For {{ campus.name }} {{ profile.entry_grade_label }} entry (Year 10 to Year 12) add information here{% endif %}

To select required text based on the entry year and current calendar year

{% if profile.entry_year == now|as_date|date:"Y"|add:0 %}

To select required text based on the entry year and the next calendar year

{% if profile.entry_year == now|as_date|date:"Y"|add:1 %}

To select required text based on both the current calendar year and the next year with an additional response for an entry year greater than 2 years in the future

{% comment %} {{now|as_date|date:"Y" }} {% endcomment %} {% if profile.entry_year == now|as_date|date:"Y" or profile.entry_year == now|as_date|date:"Y"|add:1 %} We will arrange to meet with you as soon as possible

{% else %}We will arrange to meet with you in {{ profile.entry_year|add:-2 }} and request updated information at that time.{% endif %}

To add a number of days into the future (in correct format) this example is 30 days in the future note the + sign

{{ now|as_date|add_days:+30|date:"j F Y" }}

To add a number of days in the past (in correct format) this example is 5 days in the past note the - sign

{{ now|as_date|add_days:-5|date:"j F Y" }}

To specify the year prior to application year this example is 1 year prior note the - sign

{{ profile.entry_year|add:-1 }}

To specify a different response based on the Interview type this example of for Uniform shop or Interview

{% if interview_booking.interviewer.name == 'Uniform Shop' %} add information here (this 'description' must match the Booking type exactly)

{% elif interview_booking.interviewer.name == 'Interview' %} add information here {% endif %} (this 'description' must match the Booking type exactly)

To specify different a response if the current year = profile year of entry for example, if the current year = 2025 and the profile.entry_year = 2025 it returns "under separate cover". If not, it returns ..."in Term 4" the year before the profile.entry_year.

{% now "Y" as current_year %}Important information about starting well will be sent to you {% if profile.entry_year|stringformat:"s" == current_year %}under separate cover.{% else %}in Term 4 {{profile.entry_year|add:-1}}.{% endif %}

To specify the Calendar Year of Graduation this example shows all the years from Kindergarten to Year 11

{% if profile.entry_grade == 0 %}   {{ profile.entry_year|add:"12" }}

{% elif profile.entry_grade == 1 %}   {{ profile.entry_year|add:"11" }}

{% elif profile.entry_grade == 2 %}   {{ profile.entry_year|add:"10" }}

{% elif profile.entry_grade == 3 %}   {{ profile.entry_year|add:"9" }}

{% elif profile.entry_grade == 4 %}   {{ profile.entry_year|add:"8" }}

{% elif profile.entry_grade == 5 %}   {{ profile.entry_year|add:"7" }}

{% elif profile.entry_grade == 6 %}   {{ profile.entry_year|add:"6" }}

{% elif profile.entry_grade == 7 %}   {{ profile.entry_year|add:"5" }}

{% elif profile.entry_grade == 8 %}   {{ profile.entry_year|add:"4" }}

{% elif profile.entry_grade == 9 %}   {{ profile.entry_year|add:"3" }}

{% elif profile.entry_grade == 10 %}   {{ profile.entry_year|add:"2" }}

{% elif profile.entry_grade == 11 %}   {{ profile.entry_year|add:"1" }}

{% endif %}

Note: the first line must be an IF - all subsequent lines are ELIF