{"id":9371,"date":"2024-06-06T10:28:45","date_gmt":"2024-06-06T08:28:45","guid":{"rendered":"https:\/\/churchtools.academy\/?post_type=docs&#038;p=9371"},"modified":"2025-10-07T07:48:24","modified_gmt":"2025-10-07T06:48:24","password":"","slug":"17-how-to-use-control-structures-with-placeholders","status":"publish","type":"docs","link":"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/17-how-to-use-control-structures-with-placeholders\/","title":{"rendered":"How to use control structures with placeholders"},"content":{"rendered":"\n<p>With the placeholders in ChurchTools, you can not only have individual content replaced in a customized way, but also use so-called <em>control structures<\/em> and thus personalize your e-mails, templates, etc. even further.<\/p>\n\n\n\n<p>With control structures, you can include conditions and dependencies that define whether and if so, which placeholders should be used. If you use control structures, they are highlighted purple in the editor.<\/p>\n\n\n\n<p>On this page, we would like to show you four examples of different control structures that we think are very useful. You can of course also combine them with each other. &nbsp;<\/p>\n\n\n\n<aside class=\"wp-block-group ct-box ct-box-blue has-background is-vertical is-layout-flex wp-container-core-group-is-layout-002f1c27 wp-block-group-is-layout-flex\" style=\"border-radius:8px;border-left-color:#22c55e;border-left-width:0.5rem;background-color:#dcfce7;margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)\">\n<p style=\"margin-top:0.5rem;margin-right:0.5rem;margin-bottom:0rem;margin-left:0.5rem\"><strong>Tip<\/strong><\/p>\n\n\n\n<p style=\"margin-top:0rem;margin-right:0.5rem;margin-bottom:0.5rem;margin-left:0.5rem\">If you would like to learn how to work with placeholders in ChurchTools, please take a look at our <a href=\"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/17-placeholders\/\" data-type=\"docs\" data-id=\"9374\">instructions<\/a> first.<\/p>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Gender-specific salutation<\/h2>\n\n\n\n<p>You can use <em>if-then conditions<\/em> with placeholders to ensure that placeholders are only used in certain situations or only when certain characteristics apply.<\/p>\n\n\n\n<p>For example, you can ensure that the salutation in your e-mails is always correctly adapted to the gender of your addressee.<\/p>\n\n\n\n<p>In ChurchTools, you work with the <em>ifEqual control structure<\/em>, which basically looks like this: &nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start: <code>{{#ifEqual placeholder}}<\/code><\/li>\n\n\n\n<li>End: <code>{{\/ifEqual}}<\/code><\/li>\n<\/ul>\n\n\n\n<p>For the gender-specific salutation, your combination of control structure, placeholder and text looks like this: &nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Male: <code>{{#ifEqual person.sexId 1}} Dear Mr. {{person.lastName}} {{\/ifEqual}}<\/code><\/li>\n\n\n\n<li>Female: <code>{{#ifEqual person.sexId 2}} Dear Ms. {{person.lastName}} {{\/ifEqual}}<\/code><\/li>\n\n\n\n<li>Unknown: <code>{{#ifEqual person.sexId 0}} Dear {{person.firstName}} {{person.lastName}} {{\/ifEqual}}<\/code><\/li>\n\n\n\n<li>Diverse: <code>{{#ifEqual person.sexId 3}} Dear {{person.firstName}} {{person.lastName}} {{\/ifEqual}}<\/code><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img fetchpriority=\"high\" decoding=\"async\" width=\"640\" height=\"436\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-261.png\" alt=\"\" class=\"wp-image-14148\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-261.png 640w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-261-300x204.png 300w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-261-360x245.png 360w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p>With this control structure, you define which salutation should be used, depending on which gender is stored in the user account of the addressee. The preview shows you that only the salutation that applies to the respective addressee is used and filled in.<\/p>\n\n\n\n<p><strong>Male addressee<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"340\" height=\"233\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260.png\" alt=\"\" class=\"wp-image-14151\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260-300x206.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p><strong>Female addressee<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"340\" height=\"272\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262.png\" alt=\"\" class=\"wp-image-14145\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262-300x240.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p>If you want to include the gender-specific salutation in your e-mails as shown above, you can simply copy and paste this <em>snippet<\/em>:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>{{#ifEqual person.sexId 1}} Dear Mr. {{person.lastName}} {{\/ifEqual}}<br>{{#ifEqual person.sexId 2}} Dear Ms. {{person.lastName}} {{\/ifEqual}}<br>{{#ifEqual person.sexId 0}} Dear {{person.firstName}} {{person.lastName}} {{\/ifEqual}}<br>{{#ifEqual person.sexId 3}} Dear {{person.firstName}} {{person.lastName}} {{\/ifEqual}}<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<aside class=\"wp-block-group ct-box ct-box-blue has-background is-vertical is-layout-flex wp-container-core-group-is-layout-002f1c27 wp-block-group-is-layout-flex\" style=\"border-radius:8px;border-left-color:#22c55e;border-left-width:0.5rem;background-color:#dcfce7;margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)\">\n<p style=\"margin-top:0.5rem;margin-right:0.5rem;margin-bottom:0rem;margin-left:0.5rem\"><strong>Tip<\/strong><\/p>\n\n\n\n<p style=\"margin-top:0rem;margin-right:0.5rem;margin-bottom:0.5rem;margin-left:0.5rem\">You can of course change and add to the list of salutations as you wish. To do this, you can adapt the text and define additional control structures to query further gender information.<\/p>\n<\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Default values<\/h2>\n\n\n\n<p>You can also use control structures to define default values that should be inserted if a placeholder cannot be filled in because the information is not stored in the addressee&#8217;s user account. To do this, you use the control structure <em>default<\/em>, which basically looks like this:<\/p>\n\n\n\n<p><code>{{#default placeholder 'default value'}}<\/code> &nbsp;<\/p>\n\n\n\n<aside class=\"wp-block-group ct-box ct-box-blue has-background is-vertical is-layout-flex wp-container-core-group-is-layout-002f1c27 wp-block-group-is-layout-flex\" style=\"border-radius:8px;border-left-color:#ef4444;border-left-width:0.5rem;background-color:#fee2e2;margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)\">\n<p style=\"margin-top:0.5rem;margin-right:0.5rem;margin-bottom:0rem;margin-left:0.5rem\"><strong>Caution<\/strong><\/p>\n\n\n\n<p style=\"margin-top:0rem;margin-right:0.5rem;margin-bottom:0.5rem;margin-left:0.5rem\">You must put your <em>default value<\/em> in <em>single quotation marks ( &#8216; )<\/em> and <strong>not<\/strong> in <em>double quotation marks ( &#8221; )<\/em>!<\/p>\n<\/aside>\n\n\n\n<p>For example, if you want to send an e-mail to all donors to match the addresses for sending the donation receipts via e-mail, your control structure will look like this if you use a default value for the placeholder <em>street<\/em>:<\/p>\n\n\n\n<p><code>{{#default person.street 'No street available'}}<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"233\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260.png\" alt=\"\" class=\"wp-image-14144\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-260-300x206.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p>The preview clearly shows the effect of the default value.<br>If all the information is available for an addressee, it is also filled in according to the placeholders and the default value is not used. If the information is missing, the default value is inserted.<\/p>\n\n\n\n<p><strong>All information available<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"272\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262.png\" alt=\"\" class=\"wp-image-14146\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-262-300x240.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p><strong>Some information is missing<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"253\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-263.png\" alt=\"\" class=\"wp-image-14154\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-263.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-263-300x223.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p>Our example also shows that it can be useful to work with default values to make it clear that information is missing. No default value was used for the placeholder <em>City<\/em> and the line therefore remains empty in the e-mail text. In contrast to the <em>Street<\/em> field, which is filled with the default value, it is not clear here that the city is missing. It would therefore make sense to work with a default value here as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Context change<\/h2>\n\n\n\n<p>You can use the control structures <em>each<\/em> and <em>with this<\/em> to change the context in which a placeholder is used.<br>The control structures basically look like this:<\/p>\n\n\n\n<p><strong>each<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start: <code>{{#each placeholder}}<\/code><\/li>\n\n\n\n<li>End: <code>{{\/each}}<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>with this<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start: <code>{{#with this}}<\/code><\/li>\n\n\n\n<li>End: <code>{{\/with this}}<\/code><\/li>\n<\/ul>\n\n\n\n<p>You can use this function, for example, if you want to list the names of all the addressees&#8217; children.<br>In this case, your control structure looks like this:<\/p>\n\n\n\n<p><code>{{#each relations.parent-child.child.all}} {{#with this}} - Name<\/code><br><code>{{\/with}} {{\/each}}<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"640\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-265.png\" alt=\"\" class=\"wp-image-14158\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-265.png 960w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-265-300x200.png 300w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-265-768x512.png 768w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-265-360x240.png 360w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p>In the preview you can see that the first names of all children (if the relationships are maintained in the user account) are listed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"218\" src=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-264.png\" alt=\"\" class=\"wp-image-14156\" srcset=\"https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-264.png 340w, https:\/\/churchtools.academy\/wp-content\/uploads\/2024\/06\/image-264-300x192.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Generate QR codes<\/h2>\n\n\n\n<p>QR codes can be helpful for a wide variety of situations and you can now generate them yourself with a control structure and determine the content individually.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start: <code>{{#qrcode}}<\/code><\/li>\n\n\n\n<li>End: <code>{{\/qrcode}}<\/code><\/li>\n<\/ul>\n\n\n\n<p>Between the start and end of the control structure, you can enter your content, which will be converted into a QR code. This can be the website of your church or a link to display the geographically nearest church in the ChurchTools Finder.<\/p>\n\n\n\n<p><code>{{#qrcode}}custom content{{\/qrcode}}<\/code><\/p>\n\n\n\n<p>The generated QR code is displayed in the preview so that you can check directly whether you can scan it and be guided to the desired result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Link to the church website<\/h2>\n\n\n\n<p><code>{{#qrcode}}https:\/\/www.my-church.de{{\/qrcode}}<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Link to the ChurchTools Finder<\/h2>\n\n\n\n<p>If you use the placeholder <code>{{person.city}}}<\/code> within the QR code control structure, you can generate a link that is tailored to the addressee of your e-mail and shows the church in the ChurchTools Finder that is geographically closest to the person&#8217;s address.<\/p>\n\n\n\n<p><code>{{#qrcode}}https:\/\/find.church.tools\/search?query={{person.city}}{{\/qrcode}}<\/code> &nbsp;<\/p>\n\n\n\n<aside class=\"wp-block-group ct-box ct-box-blue has-background is-vertical is-layout-flex wp-container-core-group-is-layout-002f1c27 wp-block-group-is-layout-flex\" style=\"border-radius:8px;border-left-color:#22c55e;border-left-width:0.5rem;background-color:#dcfce7;margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)\">\n<p style=\"margin-top:0.5rem;margin-right:0.5rem;margin-bottom:0rem;margin-left:0.5rem\"><strong>Tip<\/strong><\/p>\n\n\n\n<p style=\"margin-top:0rem;margin-right:0.5rem;margin-bottom:0.5rem;margin-left:0.5rem\">You can adjust the size of the QR code by inserting the number of pixels in the control structure. The default setting is 200 pixels. If you want to set 300 pixels, for example, insert the number 300 in the first part of the control structure: <code>{{#qrcode 300}}<\/code>.<\/p>\n<\/aside>\n\n\n\n<aside class=\"wp-block-group ct-artikel-zum-weiterlesen has-background is-layout-constrained wp-container-core-group-is-layout-89fd719a wp-block-group-is-layout-constrained\" style=\"border-radius:8px;background-color:#f9fafb;margin-top:24px;margin-bottom:24px;padding-top:32px;padding-right:24px;padding-bottom:32px;padding-left:24px\">\n<h4 class=\"wp-block-heading has-medium-font-size\">Read more<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/17-placeholders\/\" data-type=\"docs\" data-id=\"9374\">Overview Placeholders<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/17-placeholders-in-churchtools\/\" data-type=\"docs\" data-id=\"9375\">Placeholders in ChurchTools<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/17-how-to-use-placeholders-in-e-mails\/\" data-type=\"docs\" data-id=\"9372\">How to use placeholders in e-mails<\/a><\/li>\n<\/ul>\n<\/aside>\n","protected":false},"excerpt":{"rendered":"<p>With the placeholders in ChurchTools, you can not only have individual content replaced in a customized way, but also use so-called control structures and thus personalize your e-mails, templates, etc. even further. With control structures, you can include conditions and dependencies that define whether and if so, which placeholders should be used. If you use [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"doc_category":[483],"doc_tag":[],"knowledge_base":[426],"class_list":["post-9371","docs","type-docs","status-publish","hentry","doc_category-place-holders","knowledge_base-administration"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"year_month":"2026-04","word_count":845,"total_views":"2253","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Jasper Stehmeier","author_nicename":"jstehmeier","author_url":"https:\/\/churchtools.academy\/en\/author\/jstehmeier\/"},"doc_category_info":[{"term_name":"Place Holders","term_url":"https:\/\/churchtools.academy\/en\/help\/administration\/place-holders\/"}],"doc_tag_info":[],"knowledge_base_info":[{"term_name":"Administration","term_url":"https:\/\/churchtools.academy\/en\/help\/administration\/","term_slug":"administration"}],"knowledge_base_slug":["administration"],"_links":{"self":[{"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/docs\/9371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/comments?post=9371"}],"version-history":[{"count":7,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/docs\/9371\/revisions"}],"predecessor-version":[{"id":40936,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/docs\/9371\/revisions\/40936"}],"wp:attachment":[{"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/media?parent=9371"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/doc_category?post=9371"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/doc_tag?post=9371"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/churchtools.academy\/en\/wp-json\/wp\/v2\/knowledge_base?post=9371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}