TWiki Variables » Search » Category: Development

ADDTOHEAD -- add HTML to the HTML head section of the current page

  • Useful for TWiki applications to add custom CSS or JavaScript to the HTML head section of a topic. Supplied TWiki variables will be expanded. %ADDTOHEAD{}% expands in-place to an empty string, unless there is an error in which case the variable expands to an error string.
  • Syntax: %ADDTOHEAD{ "..." text="..." }%
  • Supported parameters:
    Parameter:Sorted descending Description: Comment:
    topic="Web.TopicName" Name of topic that contains the full HTML text to add to the head section, such as topic="Main.MyCssTopic" Mutually exclusive with text=""
    text="..." HTML text to add to the head section Mutually exclusive with topic=""
    section="name" If topic parameter is used, includes only the specified named section, as defined in the topic by the STARTSECTION and ENDSECTION variables. Nothing is shown if the named section does not exists. section="" is equivalent to not specifying a section Optional
    requires="..., ..." Comma-separated list of other IDs this one depends on Optional
    "..." ID of the head block, such as "MY_CSS" Optional but recommended
  • Category: ApplicationsAndComponentsVariables, DevelopmentVariables
  • Example: %ADDTOHEAD{ "MYBOX_CSS" text="<style type=\"text/css\"> .myBox { height: 22px; background-color: #AFB3C5; } </style>" }% (this topic)

CALCULATE{"formula"} -- handle spreadsheet calculations outside tables

  • The %CALCULATE{formula}% variable is handled by the SpreadSheetPlugin. Over 100 functions are available, such as $ABS(), $EXACT(), $EXISTS(), $GET()/$SET(), $IF(), $LOG(), $LOWER(), $PERCENTILE(), $TIME(), $VALUE().
  • Syntax: %CALC{formula}%
  • Examples:
    • %CALC{$EXISTS(Web.SomeTopic)}% returns 1 if the topic exists
    • %CALC{$UPPER(Collaboration)}% returns COLLABORATION
  • Note: The CALCULATE variable is handled inside-out & left-to-right like ordinary TWiki variables, but it does not support functions that refer to table cells, such as $LEFT() or $T(). Use CALC instead.
  • Category: DevelopmentVariables, TablesAndSpreadsheetsVariables
  • Related: CALC, IF, IfStatements, SpreadSheetPlugin (this topic)

DASHBOARD -- build a dashboard with banner and boxes

EDITFORM{} -- render a TWiki form for edit

  • Show an HTML form to update the TWiki form data of a topic.
  • Syntax to update a TWiki form: %EDITFORM{topic="..." formfields="..."}%
  • Supported parameters:                                
    Parameter: Description: Default:
    "..." or
    topic="..."
    Name of topic containing the TWiki form, such as "Bug1234". Specify topic name or Web.TopicName Either "...", topic=""
    or formtemplate=""
    is required
    formtemplate="..." Name of form template topic, such as "BugForm". Specify topic name or Web.TopicName
    elements="..." Elements of edit form: formstart is the HTML form tag, header the form header, formfields the form fields, submit the submit button, hiddenfields are hidden input fields, formend is the HTML form end tag. "formstart, header,
      formfields, submit, hiddenfields, formend"
    header="..." Form header, typically containing the form name. If "on", the default format is used:
    "
    *[[$formweb.$formtopic][$formtopic]]* "
    Supported variables:
    รข\x{fffd}ยข $formweb - name of web containing the form definition.
    รข\x{fffd}ยข $formtopic - name of topic containing the form definition.
    "on"
    formfields="..., ..." Specify names of TWiki form fields to use, in sequence. The all token shows all remaining fields. "all"
    format="..." Format of one form field. Supported variables:
    รข\x{fffd}ยข $inputfield - rendered form input field.
    รข\x{fffd}ยข $title - raw field name (includes space and other special characters).
    รข\x{fffd}ยข $name - field name (sanitized title).
    รข\x{fffd}ยข $size - size of field or selector.
    รข\x{fffd}ยข $value - initial value, or select options.
    รข\x{fffd}ยข $tooltip - tooltip message.
    รข\x{fffd}ยข $attributes - type attributes, such as H for hidden, M for mandatory.
    รข\x{fffd}ยข $extra - extra information, such as * for mandatory field.
    รข\x{fffd}ยข $formweb - name of web containing the form definition.
    รข\x{fffd}ยข $formtopic - name of topic containing the form definition.
    See details in TWikiForms#FormFieldTypes.
    " $title: $extra $inputfield "
    hiddenfields="..., ..." List of form field names to use as hidden fields. For each name listed in hiddenfields="", add a name="value" parameter to specify the value of the hidden input field. If you omit the name="value" parameter for a hidden input field, it will be excluded as a form field, even with a formfields="all". ""
    submit="..." Format of submit button row. Line separator. Variable $submit expands to submit input field with label "Save", $submit(Save) to a submit input field with specific label. "   $submit "
    onsubmit="..." Execute JavaScript when the form is submitted, optional. ""
    action="..." Specify a TWiki script (view, edit, save, ...), or the full URL of an action to take on form submit. "save"
    method="..." HTML form action method. "post" for save
    action, else "get"
    separator="..." Line separator. Variable $br expands to <br /> tag, and $n to a newline. "$n"
    default="..." Text shown when no form or form fields are found ""
  • Example: %EDITFORM{ topic="%INCLUDINGTOPIC%" }% - show HTML form to update form data of the including topic (typically used in an included header)
  • Example: Custom form in an included header to update some form field values of the base topic, including one hidden field:
    %EDITFORM{
      topic="%BASEWEB%.%BASETOPIC%"
      formfields="Priority, Status"
      hiddenfields="Updated"
      Updated="%SERVERTIME{$year-$mo-$day}%"
      submit=" | | $submit(Update) |"
    }%
  • Category: DatabaseAndFormsVariables, DevelopmentVariables, EditingAndContentUpdateVariables
  • Related: EDITFORMFIELD, ENCODE, ENTITY, FORM, FORMFIELD, META, METASEARCH, SEARCH, TWikiForms, FormattedSearch, QuerySearch, SearchHelp, TWikiScripts, TWikiTemplates (this topic)

EDITFORMFIELD{"fieldname" form=""} -- render an input field specified in a form template topic

  • Use this to create HTML forms that update TWikiForms, such as a custom "create new topic" form, or a topic header that allows users to change some form values at the top of the page. A valid form is composed of a start form type, various form fields, a submit type, and an end form type.
  • Syntax:
    • %EDITFORMFIELD{"fieldname" form="...Form"}% - create form field defined in a TWiki Form template
    • %EDITFORMFIELD{"fieldname" topic="..."}% - create form field based on a topic that has a TWiki Form & initialize its value
    • %EDITFORMFIELD{"fieldname" type="..."}% - create an HTML input field
  • Supported parameters:
    Parameter: Description: Default:
    "fieldname" The name of a TWiki form field or HTML form field. Required
    form="..." Name of form template topic, such as "BugForm". Specify topic name or Web.TopicName Either form or topic
    is required unless
    type is specified
    topic="..." Name of topic containing form, such as "Bug1234". Specify topic name or Web.TopicName
    format="..." Format string. Supported variables:
    รข\x{fffd}ยข $inputfield - rendered form input field.
    รข\x{fffd}ยข $title - raw field name (includes space and other special characters).
    รข\x{fffd}ยข $name - field name (sanitized title).
    รข\x{fffd}ยข $size - size of field or selector.
    รข\x{fffd}ยข $value - initial value, or select options.
    รข\x{fffd}ยข $tooltip - tooltip message.
    รข\x{fffd}ยข $attributes - type attributes, such as H for hidden, M for mandatory.
    รข\x{fffd}ยข $extra - extra information, such as * for mandatory field.
    See details in TWikiForms#FormFieldTypes. This parameter is ignored if type="..." is specified.
    "$inputfield"
    value="..." Initial value of input field. If omitted and if topic="..." is specified, the value is taken from the named form field. ""
    type="start" Special case: Start an HTML form. Parameters:
    "form" type="start" action="save" topic="..." method="" onsubmit="" onreset=""
    รข\x{fffd}ยข action: Specify a TWiki script (view, edit, save, ...), or a full action URL, default "view".
    รข\x{fffd}ยข topic: Specify topic name or Web.TopicName, default current topic; ignored if full action URL is provided.
    รข\x{fffd}ยข method: HTML form action method, default "post" for save action, else "get".
    รข\x{fffd}ยข onsubmit: Execute JavaScript when the form is submitted, optional.
    รข\x{fffd}ยข onreset: Execute JavaScript when the reset button is clicked, optional.
    ""
    type="end" Special case: End an HTML form. Parameters:
    "form" type="end"
    ""
    type="..." Special case: Create an input field regardless of the type defined in the TWikiForm. Used mainly for hidden fields and submit button. The nameless parameter is the field name. Supported types:
    รข\x{fffd}ยข "fieldname" type="hidden" value="..." - hidden input field.
    รข\x{fffd}ยข "fieldname" type="submit" value="..." - submit button, value is button label.
    รข\x{fffd}ยข "fieldname" type="button" value="..." onclick="..." - regular button, value is button label.
    รข\x{fffd}ยข "fieldname" type="text" value="..." size="80" - text input field.
    รข\x{fffd}ยข "fieldname" type="textarea" value="..." size="80x6" - multi line text area field, size denotes columns x rows.
    รข\x{fffd}ยข "fieldname" type="checkbox" value="..." text="..." - checkbox, text is display text.
    รข\x{fffd}ยข "fieldname" type="radio" value="..." text="..." - radio button, text is display text.
    รข\x{fffd}ยข In addition, any valid XHML and HTML5 input type is supported, such as type="date", type="file", type="image".
    Additional type-specific parameters can be supplied, such as alt="...", checked="checked", class="...", max="...", min="...", placeholder="...", src="...", style="...", width="...". Consult HTML documentation.
    ""
  • Example: %EDITFORMFIELD{ "ReleaseType" form="PackageForm" value="Beta-1" }%
  • Example: Custom form in an included header to update some values of the base topic
    %EDITFORMFIELD{ "form" type="start" action="save" topic="%BASEWEB%.%BASETOPIC%" method="post" }%
    | Priority: | %EDITFORMFIELD{ "Priority" topic="%BASETOPIC%" }% |
    | Status:   | %EDITFORMFIELD{ "Status"   topic="%BASETOPIC%" }% |
    |  | %EDITFORMFIELD{ "form" type="submit" value="Update" }% |
    %EDITFORMFIELD{ "Updated" type="hidden" value="%SERVERTIME{$year-$mo-$day}%" }%
    %EDITFORMFIELD{ "form" type="end" }%
  • Category: DatabaseAndFormsVariables, DevelopmentVariables, EditingAndContentUpdateVariables
  • Related: EDITFORM, EDITTABLE, FORM, FORMFIELD, METASEARCH, SEARCH, TWikiForms, FormattedSearch, QuerySearch, SearchHelp, TWikiScripts, TWikiTemplates (this topic)

ENTITY{string} -- encode a string to HTML entities

  • Encode "special" characters to HTML entities. Useful to encode text properly for HTML input fields.
  • Encoded characters:
    • all non-printable ASCII characters below space, including newline ("\n") and linefeed ("\r")
    • Space
    • HTML special characters "<", ">", "&", single quote (') and double quote (")
    • TWiki special characters "%", "[", "]", "@", "_", "*", "=" and "|"
  • Syntax: %ENTITY{string}%
  • Example: %ENTITY{text with "quotes" and
    newline}%
    expands to text&#32;with&#32;&#34;quotes&#34;&#32;and&#10;newline
  • Notes:
    • To protect against cross-site scripting (XSS), always entity encode text intended for HTML input fields. This is especially true if text is received dynamically via URLPARAM or the like.
      Example: <input type="text" name="address" value="%ENTITY{any text}%" />
    • %ENTITY{string}% is roughly equivalent to %ENCODE{ "string" type="html" }%, but the latter cannot handle strings that have double quotes embedded in it.
  • Category: DevelopmentVariables, FormattingAndRenderingVariables, ExportAndPublishingVariables
  • Related: ENCODE, FORMFIELD, QUERYPARAMS, URLPARAM (this topic)

EXAMPLEVAR -- example variable

  • The %EXAMPLEVAR{}% variable is handled by the EmptyPlugin
  • Syntax: %EXAMPLEVAR{"text" format="..."}%
  • Parameter text="..." - example text.
  • Parameter format="..." - format of report.
  • Example: %EXAMPLEVAR{"hello" format="| $topic: $summary |"}%
  • Category: DevelopmentVariables
  • Related: EmptyPlugin (this topic)

FORM{} -- render a TWiki form for view

  • Show a table containing data of a TWiki form attached to a topic
  • Syntax: %FORM{topic="..." formfields="..." ...}%
  • Supported parameters:                    
    Parameter: Description: Default:
    "..." or
    topic="..."
    Name of topic containing the TWiki form, such as "Bug1234". Specify topic name or Web.TopicName Current topic
    rev="..." Get the form from the specified topic revision, range "1" to top revision of topic. "0" is equivalent to the top revision The rev URL parameter value if present, else the top revision
    formfields="..., ..." Specify names of TWiki form fields to show, in sequence. The all token shows all remaining fields. "all"
    header="..." Form header, typically containing the form name. If "on", the default format " *[[$formweb.$formtopic][$formtopic]]* " is used. If "none", the header is suppressed. Supported variables:
    รข\x{fffd}ยข $formweb - name of web containing the form definition.
    รข\x{fffd}ยข $formtopic - name of topic containing the form definition.
    "on"
    format="..." Format of one form field. Supported variables:
    รข\x{fffd}ยข $title - raw field name (includes space and other special characters).
    รข\x{fffd}ยข $name - field name (sanitized title).
    รข\x{fffd}ยข $type - form field type.
    รข\x{fffd}ยข $size - size of field or selector.
    รข\x{fffd}ยข $value - form field value.
    รข\x{fffd}ยข $value(20, -<br />) - value hyphenated every 20 characters using separator -<br />.
    รข\x{fffd}ยข $value(30, ...) - value shortened to 30 characters.
    รข\x{fffd}ยข $length - length of form field value.
    รข\x{fffd}ยข $tooltip - tooltip message.
    รข\x{fffd}ยข $attributes - type attributes, such as H for hidden, M for mandatory.
    รข\x{fffd}ยข $formweb - name of web containing the form definition.
    รข\x{fffd}ยข $formtopic - name of topic containing the form definition.
    See details in TWikiForms#FormFieldTypes.
    " $title: $value "
    separator="..." Line separator. Variable $br expands to <br /> tag, and $n to a newline. "$n"
    default="..." Text shown when no form or form fields are found ""
    newline="$br" Convert newlines in textarea to other delimiters. Variable $br expands to <br /> tag, and $n to a newline. Other text is encoded based on encode parameter. "$br" if format is a TWiki table, else "\n"
    encode="html" Encode special characters in form field value into HTML entities. Additional encodings available: encode="quote", encode="moderate", encode="safe", encode="entity" and encode="url". See ENCODE for details. "" (no encoding)
    showhidden="..." Set to "on" to show also hidden form fields. ""
  • Examples:
    • %FORM{topic="%INCLUDINGTOPIC%"}% - show form data of the including topic (typically used in an included header)
    • %FORM{topic="Projects.SushiProject" formfields="Title, Status, Deadline" header="none"}% - show a subset of form fields
    • %FORM{format="$name" header="none" separator=", "}% - get all visible form field names as a list
  • Category: DatabaseAndFormsVariables, DevelopmentVariables, FormattingAndRenderingVariables
  • Related: EDITFORM, EDITFORMFIELD, ENCODE, ENTITY, FORMFIELD, META, METASEARCH, SEARCH, TWikiForms, FormattedSearch, QuerySearch, SearchHelp (this topic)

GET{"name"} -- get a variable

  • Get the value of a named variable, previously set with %SET{}%. The %SET{}% and %GET{}% variables are handled by the SetGetPlugin.
  • Syntax: %GET{ "name" default="..." }%
  • Parameters:
    Parameter Description Default
    "name" Name of variable, such as menu. May optionally contain a JSON path, such as menu.File.Open. (required)
    format="..." Format with supported variables:
    รข\x{fffd}ยข $name for variable name
    รข\x{fffd}ยข $value for variable value
    รข\x{fffd}ยข $isdefined expanding to 1 or 0 depending if variable is defined or not
    รข\x{fffd}ยข $isset expanding to 1 or 0 depending if variable is logically true or false
    รข\x{fffd}ยข $ispersistent expanding to 1 or 0 depending if variable is persistent or not
    รข\x{fffd}ยข all FormatTokens such as $dollar, $n, $percnt.
    "$value"
    default="..." Text shown if variable is not defined, e.g. not found. This parameter overrides the format parameter. "" (empty string)
    store="..." Specify a store name that holds the persistent variable. This assumes the variable was previously set with the same store name. ""
  • Example: %GET{"lunch"}% returns Sushi if the following has been previously set:
    %SET{ "lunch" value="Sushi" }% - see more examples
  • JSON Syntax: %GET{ name }% - see description.
  • Example to set a JSON object and to get a JSON object with a JSON path:
    • %SET{ menu = { "File": { "New": [ "new", "F" ], "Open": [ "open", "F" ] }, "Edit": { "Copy": [ "cpy", "F" ], "Paste": [ "pst", "F" ] } } }% - set a JSON object
    • %GET{ menu.File.Open }% - returns: ["open","F"]
  • Category: ApplicationsAndComponentsVariables, DevelopmentVariables
  • Related: IF, SET, SETGETDUMP, SetGetPlugin, SpreadSheetPlugin#FuncGET (this topic)

SET{"name" value="..."} -- set a variable

  • Set a named variable that can be retrieved later with %GET{}%. No output is shown, e.g. %SET{}% resolves to an empty string. It is also possible to set a JSON object using a JSON path. The %SET{}% and %GET{}% variables are handled by the SetGetPlugin.
  • Syntax: %SET{ "name" value="..." remember="1" }%
  • Parameters:
    Parameter Description Default
    "name" Name of variable. Alphanumeric characters, dashes and underscores can be used. (required)
    value="..." Value of variable. Escape double quotes with backslash. (required, may be empty)
    remember="1" If set, the variable will be stored persistently so that it can be used later in any TWiki topic. Alternatively use the store parameter. See important notes. "0"
    store="..." Specify a store name to persistently store the variable, such as store="Parts". Use alphanumeric characters, dashes and underscores for the name. For better performance, store is preferred over the remember parameter if you need to store a large dataset. See important notes. ""
  • Example: %SET{"lunch" value="Sushi"}% - see more examples.
  • JSON Syntax: %SET{ name = { ... } remember="1" }% - see description.
    • An optional remember="1" or store="..." parameter can be appended. If specified, the JSON object will be stored persistently so that it can be used later in any TWiki topic.
  • Example to set, modify and get a JSON object:
    • %SET{ menu = { "File": { "New": [ "new", "F" ], "Open": [ "open", "F" ] }, "Edit": { "Copy": [ "cpy", "F" ], "Paste": [ "pst", "F" ] } } }% - set a JSON object
    • %GET{ menu }% - returns: {"File":{"New":["new","F"],"Open":["open","F"]},"Edit":{"Copy":["cpy","F"],"Paste":["pst","F"]}}
    • %SET{ menu.File.Open[1] = "T" }% - modify a JSON object
    • %GET{ menu }% - returns: {"File":{"New":["new","F"],"Open":["open","T"]},"Edit":{"Copy":["cpy","F"],"Paste":["pst","F"]}}
    • %SET{ menu.Edit.Cut = [ "cut", "T" ] }% - add to a JSON object
    • %GET{ menu }% - returns: {"File":{"New":["new","F"],"Open":["open","T"]},"Edit":{"Copy":["cpy","F"],"Paste":["pst","F"],"Cut":["cut","T"]}}
  • Category: ApplicationsAndComponentsVariables, DevelopmentVariables
  • Related: GET, IF, SETGETDUMP, SetGetPlugin, SpreadSheetPlugin#FuncSET (this topic)

SETGETDUMP{...} -- dump variables

USERREPORT -- show user reports with profile pictures

  • Show various user reports documented in UserReports
  • Syntax: %USERREPORT{ action="..." ... }%
  • Overview of actions with parameters:
    Report action= Parameters
    Show a simple list of registered users "user_list" search, limit, sort, reverse
    Show the profile picture image of a user "profile_picture" user, height, width, title
    Show slim, one line height user boxes "slim_box_start"
    "slim_box" or
    "slim_box_list"
    "slim_box_end"
    style
    user, style
    users, style
    none
    Show small, two line height user boxes "small_box_start"
    "small_box" or
    "small_box_list"
    "small_box_end"
    style
    user, style
    users, style
    none
    Show users in business card format "business_card_start"
    "business_card" or
    "business_card_list"
    "business_card_end"
    style
    user, style
    users, style
    none
    Show a selector to pick a user,
    for use in HTML forms
    "select_one_user" name, selected, users
    Show rows of checkboxes to select users,
    for use in HTML forms
    "select_users" name, selected, users, colums, style
  • Example: %USERREPORT{ action="user_list" search="jane" limit="5" }%
  • Category: AdministrationVariables, DevelopmentVariables, UsersAndAuthenticationVariables
  • Related: BUBBLESIG, SEARCH, USERSIG, UserList, UserReports (this topic)

Total: 12 variables

Related Topics: TWikiVariables, TWikiVariablesSearch, TWikiVariablesQuickStart

 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.DevelopmentVariables