Help & Manual's variables have two features that make them extremely powerful and flexible:
| • | You can define variables as HTML variables or as plain-text variables |
| • | You can redefine user variables on a per-topic basis |
These two features are particularly powerful when you are generating HTML-based output. For example, you can perform search engine optimization on a per-topic basis and you can add individual JavaScript code to the HTML templates of every topic. We are sure that you will come up with additional uses for this powerful feature – experiment!
HTML variables only insert HTML code in HTML templates and HTML code objects. If you insert an HTML variable in the body of your topic only the text portion of the variable value will be used. |
Note that you can redefine both user-defined variables and global variables on a per-topic basis with this method.
The value you enter for the variable in the tab will be used in all output formats, but only in the current topic. This is rather trivial when you are just using variables in your topic text but becomes very powerful in HTML templates. |
All your topic keywords are automatically included in your topic page head section in a <meta> keywords tag. However you may want to add additional meta information yourself to fine-tune your site's search engine performance. You can do this with editable HTML variables. This simple example shows you how to do this.
<meta name="description" content="Redefining variables" />
Using the Redefining variables variable as the default value for the content attribute means that you won't have to edit the description for every single topic, just for the topics where you want to include additional information in the description.
<head> <title>Redefining variables</title> <meta name="generator" content="Help & Manual" /> <%METADSCR%> ... If you do nothing else every topic will now contain the text from the topic header as the meta description text. Next you want to redefine this text for individual topics.
This is a very simple example that just demonstrates the basic principle. Variables are so flexible that you can find a number of different ways of doing this: For example, instead of using an HTML variable for the entire line of code you could define <%METADSCR%> as a plain-text variable, enter Redefining variables as its value and use it like this: <meta name="description" content="<%METADSCR%>" /> If you do nothing the topic header text is still inserted as the description. To redefine the content for individual topics you then just need to enter the new description text, not the entire line of code. |
When you add your own JavaScript functions to your topics it is generally good practice to add the functions to the <head> section of your HTML page template and call the functions from within the topic with HTML code objects inserted in the topic. If you need different code functions in individual topics you can achieve this with editable variables. Variables containing the actual code: This assumes that you are going to insert the entire body of your JavaScript code in the <head> section of your HTML topic page template.
You can insert as much code as you like but it cannot include line breaks so you must use semicolons to terminate all statements and then remove all line breaks in your editor with search and replace before copying and pasting.
<meta http-equiv="Content-Style-Type" content="text/css" /> <link type="text/css" href="<%STYLESHEET%>" rel="stylesheet" /> <%JS_USERPOLL%> </head>
Of course, you could also use variables within your JavaScript code to replace just part of the code on a per-topic basis. Variables containing a reference to a .js file: This assumes your code is contained in an external .js file that you are referencing in your HTML topic page template.
<meta http-equiv="Content-Style-Type" content="text/css" /> <link type="text/css" href="<%STYLESHEET%>" rel="stylesheet" /> <script type="text/javascript" src="<%JS_FUNCS%>"></script> </head>
|
The <title> tag: You can redefine the current topic's <title> tag directly in the tab, in the <TITLE> Tag: field. The contents of this field are normally the same as the topic caption from the Table of Contents but if you edit it here the edited version will be inserted in the <title> tag in your HTML-based output, and this too can be useful for search engine optimization. Other redefinable template variables: Note that you can also redefine a number of HTML template variables on a per-topic basis with the Topic Variables section in . For example you can also redefine Redefining variables (normally returns the TOC caption of the topic), More Advanced Procedures > Using Variables > Redefining variables (the path to the current topic in the TOC of the project) and Redefining variables (the text from the header box above the editor). See HTML template variables in the Reference section for more details of the specialized HTML template variables available. |
You can also take redefining variables a step further: You can redefine all the variables in your entire project when you publish with a project skin or variable definition file. For full details on this see Transforming your output with skins and Skins & redefining variables. The skins method can be used from the Publish dialog and it can also apply a completely different layout and style to your entire project. The variable definition file method can only be used from the command line but it can also be used to redefine global variables, which is not possible with the skin method. |
See also:
Transforming your output with skins
HTML template variables (reference)
Page url: http://www.helpandmanual.com/help/index.html?hm_working_variables_html.htm