| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| en:create:placeholders [20.08.2016 11:16] – [Predefined Placeholders] admin | en:create:placeholders [23.10.2026 14:44] (current) – external edit 127.0.0.1 |
|---|
| * user-defined placeholders and | * user-defined placeholders and |
| * placeholders for input fields. | * placeholders for input fields. |
| | |
| | **Note:** User-defined placeholders do __not__ work on the "last page" of a questionnaire, because background data is removed from the case when the interview is completed (FINISHED=1). If necessary, create an additional second-to-last page with ''[[:en:create:functions:buttonhide]]''. |
| |
| **Tip:** Placeholders work in practically all forms of text: from the question itself to items, text elements, HTML code and so on. | **Tip:** Placeholders work in practically all forms of text: from the question itself to items, text elements, HTML code and so on. |
| |
| <code> | <code> |
| You have just stated that most people travel to work in a %vehicle%. | You stated earlier that you mostly travel to work by %vehicle%. |
| </code> | </code> |
| |
| The PHP function ''[[:en:create:functions:prepare_input|prepare_input()]]'' is used place input fields freely. The chapter [[:en:create:inputs-single|Placing Input Fields Freely]] describes the use of placeholders in this case. | In addition, there are some predefined placeholders (see below) and the possibility to [[:en:create:inputs-single|freely place input fields]] (from other questions) using placeholders. |
| |
| ===== Placeholders and Filters ===== | ===== Placeholders and Filters ===== |
| The following example demonstrates how placeholders can be combined with conditional questions. | The following example demonstrates how placeholders can be combined with conditional questions. |
| |
| In question ''SD01'' the participant's gender is prompted. In other questions, information should be collected as to how the participant responds to people of the opposite gender. To do this, a placeholder ''%person%'' is set up and is replaced in the questionnaire by either "a man" or "a woman". A second placeholder "people" is set up as the plural form. | In question ''SD01'' the participant's gender is prompted. In other questions, information should be collected as to how the participant responds to people of the opposite gender. To do this, a placeholder ''%person%'' is set up and is replaced in the questionnaire by either "a man" or "a woman". A second placeholder ''%people%'' is set up with the plural form. |
| |
| The following PHP code is placed on the page __after__ question ''SD01''. | The following PHP code is placed on the page __after__ question ''SD01''. |
| replace('%person%', 'a man'); | replace('%person%', 'a man'); |
| replace('%people%', 'men'); | replace('%people%', 'men'); |
| } elseif (value('DC02') == 2) { | } elseif (value('SD01') == 2) { |
| replace('%person%', 'a woman'); | replace('%person%', 'a woman'); |
| replace('%people%', 'women'); | replace('%people%', 'women'); |
| |
| <code> | <code> |
| What are the most important characteristics a ''%person%'' must possess in order to take on a leadership role? | What are the most important characteristics %person% must possess in order to take on a leadership role? |
| </code> | </code> |
| |
| ===== Predefined Placeholders ===== | ===== Predefined Placeholders ===== |
| |
| The following placeholders are automatically available: these IDs are __not__ allowed to be used for user-defined placeholders. The content of the placeholders can be called up for further use by using the PHP function (see column on the right). | The following placeholders are automatically available; these IDs must __not__ be used for user-defined placeholders. The contents of some placeholders can also be retrieved by a PHP function for further use (right column). |
| |
| ^Placeholder^Description^Variable in Data^PHP Function^ | ^Placeholder^Description^Variable in Data^PHP Function^ |
| |''%caseNumber%''|Ongoing Questionnaire Number|CASE|''[[:en:create:functions:casenumber|caseNumber()]]''| | |''%caseLanguage%''|Language of the ongoing interview [language code]|LANGUAGE|''[[:en:create:functions:getlanguage]]''| |
| |''%caseSerial%''|Questionnaire Authorization Code |SERIAL|''[[:en:create:functions:caseserial|caseSerial()]]''| | |''%caseNumber%''|Serial number of the interview|CASE|''[[:en:create:functions:casenumber]]''| |
| |''%caseToken%''|Internal Questionnaire ID|-|''[[:en:create:functions:casetoken|caseToken()]]''| | |''%caseSerial%''|Participation code or personal ID of the interview|SERIAL|''[[:en:create:functions:caseserial|caseSerial()]]''| |
| |''%reference%''|Reference Given to the Questionnaire|REF|''[[:en:create:functions:reference|reference()]]''| | |''%caseToken%''|Internal ID of the interview|-|''[[:en:create:functions:casetoken|caseToken()]]''| |
| | |''%reference%''|Reference that was passed to the questionnaire|REF|''[[:en:create:functions:reference|reference()]]''| |
| | |''%pageNumber.abs%''|Number of the current page according to **Compose Questionnaire** (be careful when using filter questions)||| |
| | |''%pageNumber.cnt%''|Number of the page according to **Compose Questionnaire** from which the content of the page originates -- same as ''%pageNumber.abs%'' as long as no ''[[:en:create:functions:gotopage]]'' is used to jump to another page and a question or other content was displayed there.||| |
| | |''%pageNumber.rel%''|Number of the current page counted since the beginning of the interview (not compatible with ''[[:en:create:functions:gotoquestionnaire]]'', ''[[:en:create:functions:multileveldown]]'' and the function **Collected Data** -> **Restart an Interview Case**)||| |
| | |''%lang.label%''|Name of the active language version (e.g. "English")||| |
| | |''%lang.short%''|2-letter abbreviation of the active language version (e.g. "EN")||| |
| | |''%year%''|4-digit year (for example, for use in the footer)||''date('Y')''| |
| |
| The following placeholders are available within an item or option (e.g., in the item text). The numbering helps, e.g., to give randomly rotated options continuous numbers. | The following placeholders are available within items or options (e.g. in the item text). The numbering helps, e.g., to number randomly rotated options consecutively. |
| |
| ^Placeholder^Description^Example^ | ^Placeholder^Description^Example^ |
| |''%i.n.%''|Position of the item within the question plus point and blank|1. | | |''%i.n.%''|Number of the item followed by a period and a space|1. | |
| |''%i.a)%''|Position of the item (lower case letter) plus bracket|a) | | |''%i.a)%''|Number of the item followed by a bracket (lower case letter)|a) | |
| |''%i.num%''|Position of the item (numeric)|1| | |''%i.num%''|Number of the item within the question (numeric)|1| |
| |''%i.num.a%''|Position of the item (lower case letter)|a| | |''%i.num.a%''|Number of the item within the question (lower case letter)|a| |
| |''%i.num.A%''|Position of the item (upper case letter)|A| | |''%i.num.A%''|Number of the item within the question (upper case letter)|A| |
| |''%i.cnt%''|Number of items within the question|5| | |''%i.cnt%''|Number of items within the question|5| |
| |
| The following placeholders are designated for use exclusively in the HTML template of a layout. | The following placeholders are available in some (not yet all) error messages, which can be customized under **Text Elements and Labels**. If the affected question has no number, the placeholder is left blank (removed). |
| | |
| | ^Placeholder^Description^Example^Example^ |
| | |''%q.desc%''|Description of the question(s) concerned|question 1|questions 2,3| |
| | |''%(q.desc)%''|Description in brackets|(question 1)|(questions 2,3)| |
| | |''%q.list%''|Number(s) of the question(s) concerned|1|2,3| |
| | |
| | The following placeholders are designated exclusively for use in the HTML template of a layout. Further placeholders for the layout are documented under [[:en:create:layout#full_customization|Questionnaire Layouts: Full Customization]]. |
| |
| ^Placeholder^Description^ | ^Placeholder^Description^ |
| |''%imprint%''|HTML code for the footer/contact information| | |''%imprint%''|HTML code for the footer/contact information| |
| |''%progress%''|HTML code for the progress bar| | |''%progress%''|HTML code for the progress bar| |
| |''%head%''|HTML code for the header in the layout template| | |''%head%''\ ''%%<link type="placeholder" href="head">%%''|HTML code for the header in the layout template\ (HTML compliant variant)| |
| |''%questionnaire%''|HTML code for the content in the layout template| | |''%questionnaire%''|HTML code for the content in the layout template| |
| |
| In order to use placeholders efficiently, basic knowledge of PHP programming ([[php|PHP Code]] and experience with [[variables|variables]]) is required. | In order to use placeholders efficiently, basic knowledge of PHP programming ([[php|PHP Code]] and experience with [[variables|variables]]) is required. |
| |
| In the following example one of three possible brands (code 1, 2 oder 3) is selected from an urn ([[:en:create:random_urns|Randomization Using Urns]]). After this, a placeholder is employed to use the brand directly in the question title. | In the following example one of three possible brands (code 1, 2 or 3) is selected from an urn ([[:en:create:random_urns|Randomization Using Urns]]). After this, a placeholder is employed to use the brand directly in the question title. |
| |
| <code php> | <code php> |
| <code> | <code> |
| "Please evaluate the following statements in light of %brand%!" | "Please evaluate the following statements in light of %brand%!" |
| Item 1: "I find %brand% better than oFb" | Item 1: "I find %brand% better than SoSci Survey" |
| Item 2: "%brand% looks more artificial" | Item 2: "%brand% looks more artificial" |
| </code> | </code> |
| ==== Text Input ==== | ==== Text Input ==== |
| |
| The prerequisite for the following example is that a brand name is prompted in the open text field ''TX01_01''. The following PHP code __cannot__ be put on the the same page as the question ''TX01'', but must be put on one of the following pages instead. | The prerequisite for the following example is that a brand name is prompted in the open text field ''TX01_01''. The following PHP code __cannot__ be put on the same page as the question ''TX01'', but must be put on one of the following pages instead. |
| |
| <code php> | <code php> |