Making Help Authoring a Pleasure to Do
Free DownloadStart your free trial now
Making Help Authoring a Pleasure To Do

How to Use Variables in Your HelpSmith Project

HelpSmith allows you to use variables in different places of your help project. When you compile your help project as a CHM help file, Web Help system, or PDF document, all variables are replaced with their actual values.

For example, you can use system variables to display the current date and time, the help file’s title, the current topic’s title, or you can define custom variables to display the product name, product version, or any other data that you need.

How to Define Custom Variables

If you need to insert a custom variable (e.g. ProductName), you can simply define it as a project level variable.

  1. On the Project tab, click Project Objects, and then click Text Variables.
  2. In the Text Variables dialog, in the left side, click User Variables.
  3. On the toolbar, click the Add button.
  4. In the New Variable dialog, define the variable name (e.g. ProductName), and the variable value that you need.
Editing User-Defined Variables
Editing User-Defined Variables

After you have defined a variable on the project level, you can use it in any place of your help project including topics, templates, custom HTML code, etc.

However, if necessary, you can also re-define the values of existing variables on the level of a specific compilation task, on the level of specific topics, or when using the command line compilation.

How to Insert a Variable

In your help project, you can insert a variable in different places including the content of a topic, the content of a template (which can be applied to a series of topics), the values of different parameters in the project options section, the HTML code insertions, HTML-based templates, custom code of the <HEAD> section in the generated HTML files, etc.

To Insert a Variable into a Topic or Template:

  1. On the Project Manager pane, select the topic or template that you need.
  2. In the word processor, put the text cursor where you want to insert a variable.
  3. On the Insert tab, in the Placeholders group, click Text Variable.
  4. In the popup menu, select the variable that you need.
Inserting a Variable into a Topic
Inserting a Variable into a Topic

In other places of your help project, you can use special syntax that allows you to insert variables inside a textual value (e.g. %ProductName%), or inside HTML code (e.g. <%ProductName%>). For more details, you can also visit this topic.

How to Define Variables for Specific Topics

While you can define variables on the project level, since HelpSmith 8.4 it is also possible to define variables for specific topics. Thus, you can use this capability if you need to store some topic-related data.

To Define Variables for Specific Help Topics:

  1. In the Project Manager, select the topics that you need.
  2. Right-click on the selected topics, then click Text Variables.
Defining Variables for Specific Topics
Defining Variables for Specific Topics

For example, after you have defined variables for selected help topics, you can then insert and display these variables in a common template which applies to these topics, or in the custom code which you can include to the <HEAD> section of the generated HTML files.

Download HelpSmith

It should be noted that we have recently released HelpSmith 8.4 (Build 21.108) that fixes a minor issue because of which the system variables related to the current topic (#TopicTitle, #TopicID, and #TopicContext) did not work in HTML code insertions, and in the code of the <HEAD> section.

You can download the latest HelpSmith version here.