Translations of this page:
 

textlink()

string textlink(string textID, mixed label, [int width, int height])

It is equally possible to display text (e.g. a lengthy label) in a new window (pop-up), instead of directly in the questionnaire. The text will appear in the same layout as it would in the questionnaire.

  • textID
    ID of the text element to be shown in the pop-up window.
  • label
    Label of the hyperlink (text or HTML code) that opens the pop-up.
    • <string> – Label independent of the language version
    • <array> – Label according to language version. The ID of the language version (e.g. “ger” or “eng”) is used as the key of the array, the actual label is used as the associated value.
  • width
    Width of the pop-up window in pixels (optional).
  • height
    Height of the pop-up window in pixels (optional).

Tips

Note: This function only creates the link. You still have to place the link in the questionnaire using html() or placeholders.

Note: Only users of the questionnaire can access the text by clicking on the link generated.

Tip: The size of the new window can be specified optionally. It often makes sense to keep the window small so the questionnaire can still be seen in the background. If no size is specified, the default size of 600 × 500 pixels is used.

Tip: If you do not want to open a separate window in the questionnaire when displaying a short amount of text – who knows if the participant can find their way back to the questionnaire afterwards – then read the following chapter: Click to Get Information

General Example

For the following example, a new text element with the ID “explanation” must be created first of all in Text Elements and Labels. After this, the following PHP code is put on a page in the questionnaire.

// Save the HTML code for the link in the PHP variable $link 
$link = textlink('explanation', 'here');
// Display the link in the questionnaire
html('<p>Please click '.$link.'</p>');

The following PHP code delivers the same result – it's just a little bit more complex.

html('<p>Please click '.textlink('explanation', 'here').'</p>');

Often, it is simpler to place the link in the questionnaire using placeholders. The following PHP code is put above a question that uses the placeholder %link% in the question title.

replace('%link%', textlink('explanation', 'here'), 'html');

Control the size of the pop-up

The following PHP code opens a pop-up window with a size of 640 × 400 pixels.

$link = textlink('explanation', 'statement', 640, 400);
html('<p>If necessary, please read '.$link.'</p>');

Multilingual Surveys

Depending on the language version, either “Text nochmal zeigen” or “Display Text Again” is displayed as a link.

$link = textlink('stimulus', array(
  'ger' => 'Text nochmal zeigen',
  'eng' => 'Display the Text Again'
));
html('<p><strong>'.stimulus.'</strong></p>');
en/create/functions/textlink.txt · Last modified: 29.09.2020 18:23 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki