Logga

Script - Variables

Variables make it possible to declare variables outside the code itself. These variables are then easier to adjust without having to go in and read (or understand) the script.

Use

Variables can be added, edited, and deleted.

Add variables

When a variable is added, it must be given a variable name (which is also what you type in the code to use the variable.) You specify with a checkbox if it is mandatory to assign a value to the variable.

You can provide a description to facilitate future adjustments to the variable 

Finally, you select the variable type and can assign an initial value to the variable.  

Available variable types

  •  Boolean value
  • Single selection
  • Multiple selection
  • Style sheet
  • Colour
  • Integer
  • Metadata
  • Node in image archive
  • Node in file archive
  • Node in page tree
  • Page template
  • Text

Use

To use a variable in the script, enter scriptVariables.VARIABLENAME (JavaScript) or $scriptVariables.VARIABLENAME (Velocity).

In the script, the variable can then be used in the same way as variables declared inside the script.

Variables and Elements

The variable function is especially useful when using the Script module in an Element. The script variables can then be exposed as configurable parts of the Element.

Once the Element has been exported and added as an add-on module, the script variables are configurable for whoever sets the module.

More information about Elementopens in new window

The page published: 2019-01-02

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro
Sweden


Info: +46 19-17 30 30
Support: +46 19-17 30 39