Overriding Variable Definitions in Topics and Snippets

The variables that you create and define in the Variable Set Editor are available to your entire project. However, if you want the definition for a variable to be different for one or more snippets in a file such as a topic or template page, you can override the file- or snippet-level definition of the variable.

How to Override a Snippet Variable Definition in a Topic

Use this option if you want to change the definition of all of the variables that appear in snippets in a single file such as a topic or template page. File-level snippet variable definitions take priority over your original variable definitions or target-level variable definitions.

  1. Open the Content Explorer.
  2. Locate the file in which you want to override a variable definition.
  3. In the local toolbar, click Display properties for the selected item.. The Properties dialog for the topic opens.
  4. Click the Snippet Variables tab. The Snippet Variables tab shows all of the variable sets in your project and their associated variables.
  5. Select the appropriate variable set.
  6. Do one of the following, depending on whether the variable has only one or multiple definitions in the Variable Set Editor. For information on adding multiple definitions, see Editing Variables and Editing Date/Time Variables.
    • Single Definition Click in the Definition cell for the variable that you want to override and press F2 on your keyboard. Then type a different definition and press ENTER on your keyboard.
    • Multiple Definitions In the Definition cell, click the down arrow and select an alternative definition.

  7. Click OK.
  8. Click Save the active file. to save your work. The alternative variable definition will be used for all instances of the variable that appear in snippets in a topic. However, if the variable appears elsewhere in a topic (i.e., not in a snippet), or in other topics in the project, the original variable definition (or the target-level variable definition, if applicable) will be used.

How to Override a Snippet Variable Definition in a Snippet

Use this option if you want to change the definition of a variable within a specific snippet. Snippet-level snippet variable definitions take priority over topic-level snippet variable definitions.

  1. Open the Content Explorer.
  2. Locate the topic in which you want to override a variable definition.
  3. In the topic, right-click the instance of the snippet in which you want to override the variable definition and select Snippet Variables from the context menu.

    The Snippet Variables dialog opens. The Snippet Variables dialog shows all of the variable sets in your project and their associated variables.

  4. Select the appropriate variable set.
  5. Do one of the following, depending on whether the variable has only one or multiple definitions in the Variable Set Editor. For information on adding multiple definitions, see Editing Variables and Editing Date/Time Variables.
    • Single Definition Click in the Definition cell for the variable that you want to override and press F2 on your keyboard. Then type a different definition and press ENTER on your keyboard.
    • Multiple Definitions In the Definition cell, click the down arrow and select an alternative definition.

  6. Click OK.
  7. Click Save the active file. to save your work. The alternative variable definition will be used for all instances of the variable that appear in the selected snippet. However, if the variable appears elsewhere in the topic (i.e., in other snippets or outside of snippets) or in other topics, the topic-level snippet variable definition, the target-level variable definition (if applicable), or the original variable definition will be used.

Examples

Example — Different Types of Variable Definitions

Use the examples below to help you determine which type of variable definition you should use.

  • Original Variable Definitions Used in most cases. These are the variable definitions you enter in the Variable Set Editor. You can enter primary and alternate variable definitions.

  • Target-Level Variable Definitions Used when generating output for specific targets. Overrides the project-level variable definition, but only for the defined target. For example, if you use a company name variable in your documents, you may want to change it to say "ABC Corporation" in one document and "XYZ Company" in another.

    For more information, see Overriding Variable Definitions in Targets.

  • Topic-Level Variable Definitions Used to change a variable definition in a single topic. Applies only to variables in snippets, and overrides project-level and target-level variable definitions. For example, if you use a phone number variable throughout your project, but a handful of topics are about a different location (and therefore use a different phone number), you can set a different variable definition that applies only to those topics.

  • Snippet-Level Variable Definitions Used to change a variable definition in a single snippet. Applies only to variables in snippets, and overrides project- and target-level variable definitions, as well as topic-level snippet variable definitions. For example, if you use a product name variable throughout your project but a few snippets refer to a different product, you can set a different variable definition that applies only to those snippets.

What’s Noteworthy?

Note If you click the Edit Set button at the bottom of the tab, the Variable Set Editor opens. When you use that editor, you are editing all variables, not those for a specific snippet or target.

Note You can also override variable definitions for an entire target. For more information see Overriding Variable Definitions in Targets.