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.
- On the Project tab, click Project Objects, and then click Text Variables.
- In the Text Variables dialog, in the left side, click User Variables.
- On the toolbar, click the Add button.
- In the New Variable dialog, define the variable name (e.g. ProductName), and the variable value that you need.
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:
- On the Project Manager pane, select the topic or template that you need.
- In the word processor, put the text cursor where you want to insert a variable.
- On the Insert tab, in the Placeholders group, click Text Variable.
- In the popup menu, select the variable that you need.
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:
- In the Project Manager, select the topics that you need.
- Right-click on the selected topics, then click Text Variables.
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.