variable1Add my vote for this tag create new tag
, view all tags
ALERT! NOTE: This is a DistributionDocument. Please help maintain high quality documentation: This is a wiki, please fix the documentation if you find errors or incomplete content. Put questions and suggestions concerning the documentation of this topic in the comments section below. Use the Support web for problems you are having using TWiki.

VAR{"NAME" ...} -- get a preference value from another web or topic and more

  • Gets the value of a variable in various manners.
    • If the topic parameter is specified, it gets the value of the specified preferences variable in the specified topic. Please note that the WebPreferences of the web of the specified topic is not examined. So the returned value may not be the same as the value of the variable when the specified topic is viewed.
    • If the topic parameter is not specified and the web parameter is specified, it gets the value of the specified preferences variable in the specified web, which means the specified web's WebPreferences is examined for the variable.
    • If the neither the topic nor web parameter is specified, it gets the value of the specified variable in the current context -- the variable can either be a preferences variable or a session variable but cannot be a tag with a tag handler (e.g. %GMTIME%).
      %VAR{"NAME"}% is similar to %NAME%, but they differ if NAME is undefined, in which case %VAR{"NAME"}% is expanded to null (zero width string) while %NAME% remains as is (%NAME%). %VAR{"NAME"}% yields the same value as %IF{"defined NAME" then="$percntNAME$percnt"}% if NAME is a variable, but the latter is cubmersome.
  • Syntax: %VAR{"NAME" ...}%
  • Supported parameters:
    Parameter: Description: Default:
    "Variable" The name of the variable to be retrieved. If not specified, %VAR{...}% is expanded to null. required
    topic="Web.Topic" Specifies the topic in which the specified preferences vaiable is fetched. none
    topic="Topic" Same as above, but the web is specified specified explicitly with the web parameter or the current web is specified. none
    web="Web" Specifies the web in which the specified preferences variable is fetched. none
    default="Value" Specifies the value to be returned if the specified variable is undefined. "" (null string)
    ignorenull="on" If specified, a null string ("") value is regarded as undefined. This affects whether or not the value specified by the default parameter is returned. "off"
  • Example 1: To get the members of TWikiAdminGroup, %VAR{"GROUP" topic="%USERSWEB%.TWikiAdminGroup"}%, which expands to HideyoImazu, PeterThoeny, SopanShewale, VickiBrown.
  • Example 2: To get %WEBBGCOLOR% of the Main web write %VAR{"WEBBGCOLOR" web="Main"}%, which expands to #FFEFA6
  • Example 3: Let's say you are writing the "foo" skin. And you want to have the users specify a string inserted in the head tag with FOOSKIN_HTML_HEAD_HOOK. That can be achived by the following:
    %VARVAL{"FOOSKIN_HTML_HEAD_HOOK" default="<nop>" ignorenull="on"}%
  • Category: DevelopmentVariables, SystemInformationVariables

Comments & Questions about this Distribution Document Topic

Please use the Support forum if you have questions about TWiki features. This comment section is about the documentation of this topic.
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2014-12-16 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.