Navigation:  More Advanced Procedures > Using HTML Templates >

Conditional output in HTML templates

Print this Topic Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

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, eBooks and Visual Studio Help / MS Help 2.0. 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.

Conditional output reference

For more information on the available output conditions, variables and how to use them see the following topics:

How to use include options in HTML templates

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.

How to use user-defined conditions

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 Configuration > Common Properties > Custom Builds:

Syntax:

Opening tag:< + IF_ + OPTION + >
Closing tag:</ + IF_ + OPTION + >
NOT version:< + IFNOT_ + OPTION + >
NOT closing tag:</ + IFNOT_ + OPTION + >

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>

See also:

HTML template output conditions (reference list)

Editing HTML templates

Variables in HTML templates

 


Page url: http://www.helpandmanual.com/help/index.html?hm_advanced_htmltemplates_conditions.htm