You can use all of Help+Manual's standard conditional output options in HTML templates, both your user-defined include options and options based on the current output format. In addition to this there are a few special conditional switches which are only for use in WebHelp output, because they are only relevant there. See the lists below for details.
These conditions are used to enclose blocks of HTML code in your template that you want to include in the output only if the condition is fulfilled. The condition tags themselves are never included in your output code, they are always stripped from the code before publishing.
Conditions based on the output format are only relevant in the HTML topic page templates which are used in HTML Help, WebHelp, Windows Exe and ePUB eBooks and Visual Studio Help. The TOC, search and keyword index templates are only used in WebHelp so it does not make sense to use format-based conditions there since the output format is always WebHelp.
If you are using an HTML skin you must edit your templates and settings in the skin!
Nowadays you will almost always choose an HTML skin to publish your project to WebHelp or HTML Help/CHM. A skin is a special kind of Help+Manual project without topics that only stores your HTML templates and all the settings relevant for HTML output to these two formats. When you choose a skin, the templates and settings in the skin completely replace those in your project.
Normally, a skin is pre-designed and you don't need to change anything. However, if you do want to change something, you must do all your editing in the .hmskin skin file. Editing in your Help+Manual project won't have any effect because those templates and settings are not used.
To edit a skin, make a copy of the .hmskin skin file in your project folder and then open it in Help+Manual by selecting .hmskin as the file type to open in the dialog. All the templates and settings are in the same places as in a normal Help+Manual project.
Exception: HTML Export Options
The HTML Export Options section is not stored in skins and needs to be edited in your project.
Conditional tags in HTML templates look very similar to the conditions you use for content in your project. However, there is one very important difference: In templates, the true/false status of the conditions is hard-wired to the output format and cannot be changed.
In the Publish screen you can include content tagged for other output formats than the one you are currently publishing to by activating the checkboxes for those formats manually. This has no effect on the conditional tags in your templates, however. This is very important, because in templates you will often want to exclude code that would cause errors in some output formats. If this wasn't the case, including content tagged for WebHelp in a CHM file the Publish screen could cause serious errors if that also included template code tagged exclusively for WebHelp in a CHM file.
|
Like most HTML tags each condition has an opening tag and a corresponding closing tag, using the same </ syntax to identify the closing tag as all regular tags. Simply enclose the code you want to include conditionally between the two tags.
Note that the ELSE condition is not available in HTML templates.
Examples:
<IF_TOPIC_HEADER>
<font size="3">This text only appears in the topic if the topic has a <b>header</b>.<br><br>
It will not be included in popup topics, which never have a header, or in topics assigned
help window types defined without a header.</font>
</IF_TOPIC_HEADER>
<IFNOT_PREVIOUS_PAGE>This text will only be displayed in
the very first topic in your help.</IFNOT_PREVIOUS_PAGE>
<IF_NEXT_PAGE>
<a href="<%HREF_NEXT_PAGE%>">Click here to jump to the next topic</a>
</IF_NEXT_PAGE>
The last example only displays the link if there is a next topic to jump to.
|
Basically this is exactly the same as using the predefined include options, you just have to use the following syntax rules to create your conditional switches from the names of your include options in :
Syntax:
Examples:
This example shows how to use the user-defined include options ALPHABUILD and BETABUILD:
<IF_ALPHABUILD>
This text will be included if ALPHABUILD is selected in the Include Options in the
Make Help File & Run dialog.
</IF_ALPHABUILD>
<IFNOT_BETABUILD>
This text will be excluded if BETABUILD is selected in the Include Options in the
Make Help File & Run dialog.
</IFNOT_BETABUILD>
|
If you want to allow for multiple conditions with OR or AND logic in your HTML templates you can do this as well.
Multiple conditions with AND logic
If you want to include content in a template only if multiple conditions are all true, you just need to nest the condition tags. Then the content inside the conditions will only be included if all the tags in the nesting chain are true. For example, suppose you want to include some code only if the output is a CHM file and the user-defined option CLIENT1 are both true:
<IF_CHM><IF_CLIENT1>
This text will only be included if both CHM and CLIENT1 are true.
</IF_CLIENT1></IF_CHM>
The order is irrelevant, but you must be careful not to "cross" the end tags. In the example above, both CLIENT1 tags must be inside the CHM tags.
Multiple conditions with OR logic
If you want to include content in a template if any one of multiple conditions is true you can include multiple conditions inside a single tag, separated by the | character.
Important:
Note that this does not work with IFNOT conditions, only with IF conditions!
<IF_CHM|HTML|CLIENT1>
This text will be included if any one or more of the 3 conditions is true.
</IF_CHM|HTML|CLIENT1>
Here too, the order is irrelevant, but you should use the same order in the start and end tags.
|
See also:
HTML template output conditions (reference list)
Editing HTML templates
Variables in HTML templates