====== getTextElement() ====== The function ''getTextElement()'' returns the content of a text (text element or text in the list of questions) as a string. The optional second parameter can either (only) set the output format or specify additional settings and placeholders. ''string **getTextElement**(string //textID//, [string //outputFormat//])'' ''string **getTextElement**(string //textID//, array //settings//)'' * //textID//\\ ID of the text element whose content shall be returned. * //outputFormat// * Optionally, you can specify in which format the content is returned. * ''%%'block'%%'' -> (default) HTML code in a block element (with spacing and alignment) * ''%%'html'%%'' -> Only the actual content as HTML code * ''%%'plain'%%'' -> Unformatted text with line breaks * Or you can retrieve a specific content of the text element (as unformatted plain text) * ''%%'header'%%'' -- Heading * ''%%'content'%%'' -- Content without heading * ''%%'title'%%'' -- Title or question text in the display "like a question" * ''%%'explanation'%%'' -- Explanations/instructions * //settings//\\ Optionally, settings and placeholders can be defined * ''%%'format'%%'' -> Output format as above * ''%%'%key%'%%'' -> Placeholders that are replaced in the text element before output **Note:** If the text element is displayed in the questionnaire with a title and/or formatting, this is also included in the HTML code. However, a possible alignment (left/centered/right/justified) and the spacing below the text element are not included. ===== Example 1 ===== In the following example, one of 2 text elements ("desc1" or "desc2") is included via placeholder into a third text element ("description"). The third text element must contain the placeholder ''%desc%''. if (value('AB01_01') == 1) { $desc = getTextElement('desc1', 'html'); } else { $desc = getTextElement('desc2', 'html'); } replace('%desc%', $desc); text('description'); ===== Example 2 ===== In the following example, each "a" and each "A" is replaced with an underscore, and the text element is subsequently displayed. $content = getTextElement('priming'); $out = str_replace(array('a','A'), '_', $content); html($out); ===== Example 3 ===== Here, a text ''TX01'' with the display "HTML code" was defined, which contains several placeholders:
%source.name%
%headline%
This text element is used several times in the questionnaire, and the placeholders are filled differently each time, e.g. $html = '
'; $html.= getTextElement('TX01', [ '%num%' => 1, '%image%' => 'image01.jpg', '%source.logo%' => 'source07.png', '%source.name%' => '24/4 News', '%headline%' => 'ABC representatives visit Helsinki, difficult talks expected.', 'format' => 'html' ]); $html.= '
'; html($html);