Variables

Variables allow you to enter a string that can be inserted in topics, topic titles, master pages, snippets, index entries and a table of contents. They are used where the string could change in the future. Company and product names are good examples. Instead of having to edit every place the company or product name is used, you insert a variable. When the value of that variable changes, you change it once and it cascades to wherever you have used it.

Another scenario is where you need to change the string in different outputs. For example, you might want one output for your US customers, one for your UK customers and one for your Canadian customers. You can create Variable Sets to create different outputs.

Adding a Variable

To add a variable, click the + icon and enter the name and default value for the variable.

To view, edit or delete it, click the menu that appears when you hover over the variable. You can also double click to edit.

The name of the variable does not have to include an underscore.

To use the variable, just drag it to where you want in the topic or press CTRL + Shift + 9 to display a dialog with the variables listed.

To add a variable to the Title of an Output, place the cursor where you want the variable press CTRL + Shift + 9 to display the dialog.

Editing a Variable

  • You can open it from the Variables panel
  • If you are working on a topic containing the variable, click in the variable and select Edit Variable from the context menu.

Formatting Variables

Formatting All Instances of a Variable

If you enter a simple string into the variable, it will take on the format of the paragraph it is in.

  • The first variable shown below does not have any inline styling in its value, it has taken on the normal paragraph style. 
  • In the second variable shown below  inline styling has been applied so the variable will always show "Warning" in red.



 "Warning - Red" has to be written as you see it above. If you are not sure what HTML is required for your variable, create it in a topic, switch to code view and copy/paste it from there.

Formatting a Specific Instance of a Variable

Click in the variable and the properties for that instance of the variable will be shown on the right.

Using the example above if you click in the first variable you can change the font colour in the font settings. The chosen colour will then be shown in the authoring area.

Thus if you see the default green colour, you will know the variable will be displayed in the default for the paragraph, if you see anything else then that is how it will appear in the output for just that instance of the variable.

You can use the left icon to update the appearance of the variable by clicking the first icon and you can clear any formatting you have applied to this instance of the variable by clicking the second icon.

Variable Sets

Having created your variables with their default values, the next stage is to create the values that will vary.

Let's say the default values are for US users, in Output mode you click Variable Sets and click the + icon to create say UK Values. All the variables you have created will be listed and you can apply the UK values.

Repeat the process for all the sets you require.

Later if you tick the check boxes, a Reset button allows you to revert any or all the values to the default values so that you can start again.

The Sets are selected when you configure an output.

Donations

If you find the information and tutorials on my site save you time figuring it out for yourself and help improve what you produce, please consider making a small donation.