IF_DEFAULT_PAGE?

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

Post Reply
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

IF_DEFAULT_PAGE?

Unread post by michal_novomesky »

I want to set a condition for a default topic which is generated as index.html in HTML (webhelp) output.

There's an option <IF_PREVIOUS_PAGE> in manual
https://www.helpandmanual.com/help/hm_r ... conds.html
, but can be used only if the topic is first in Table of Contents.

Is it possible to add this additional condition, something like <IF_DEFAULT_PAGE>?
This will enable us to add custom HTML content using H&M ootb functionality only to file index.html.
User avatar
Tim Green
Site Admin
Posts: 23154
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by Tim Green »

Hi Michal,

There isn't an IF_DEFAULT_TOPIC condition, but you can easily make one (and do a lot of other cool things) with the IF_VAR and IFNOT_VAR conditions, which test the current value of variables. The restriction is that this condition can only be used in HTML templates.

1) To do this, first define a variable in your topic that you are going to use to identify the default topic (let's say this variable is called DEFAULT), and give it a standard value that means the current topic is NOT the default (for example 0).

2) Then in the default topic select the Topic Options tab, and in the topic variables section at the bottom, add your DEFAULT variable and set its value to what you want to use to indicate that it IS the default topic (for example 1).

3) Then you can use the following IF_VAR and IFNOT_VAR conditions in your HTML topic page template:

Content when the current topic IS the default:

Code: Select all

<IF_VAR[DEFAULT=1]>This is the default topic!</IF_VAR[DEFAULT=1]>
Content when the current topic is NOT the default:

Code: Select all

<IFNOT_VAR[DEFAULT=1]>This is NOT the default topic!</IFNOT_VAR[DEFAULT=1]>
Important: No spaces before or after the = sign, no quotes!
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by michal_novomesky »

Thanks, Tim, <IF_VAR> seems to be an interesting feature. I haven't seen this condition in documentation.

Are there any other hidden features like <IF_TOPICNAME[INTRODUCTION]>? :)

Unfortunately, for techwriters it means to edit 40 existing H&M projects, add a new DEFAULTPAGE condition for each project's default topic and customize the DEFAULTPAGE condition for the default topic. It's also not bulletproof.
A pre-defined condition in .hmskin after I click "Set as Default Topic" for a desired item in Table of Contents - seems to be most optimal and clean solution. Is there a way how can I request this feature?
User avatar
Tim Green
Site Admin
Posts: 23154
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by Tim Green »

Hi Michal,

This feature is not documented because it was added primarily for our own skins. Another similar feature you may find useful is the ability to resolve variables (and the IF_VAR condition) in CSS and JS files in the Baggage of skins. This setting can only be set in skins, and is a checkbox at the bottom of the Configuration > Common Properties > Text Variables section (it is not shown in normal projects).

You can post a feature request in the Wish List section of the forum. It is monitored by our developers. I'm also going to check with them to see if it can be added in the future. Sometimes these things can be added very quickly, but I can't promise this. 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Tim Green
Site Admin
Posts: 23154
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by Tim Green »

Hi Michal,

Update: It's already in, you can get it with this pre-release build:

https://www.helpandmanual.com/download/ ... p-v841.exe

IMPORTANT:

The new conditions are <IF_ISDEFAULT_PAGE> and <IFNOT_ISDEFAULT_PAGE>. This was chosen to make a clear distinction between this and conditions like IF_INDEX_PAGE. These are always true anywhere, if the WebHelp is exported with an index. In contrast to this, IF_ISDEFAULT_PAGE is only true if the current topic is the default topic.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by michal_novomesky »

Wow, that was quick, thank you! :)

Just to confirm:
* IF_ISDEFAULT_PAGE works for every HTML page generated as index.html? (the default topic is not always selected in Table of Contents (represented by an icon) and the default topic is considered then as first item in TOC).
* will be this condition a part of H&M documentation as well?
User avatar
Tim Green
Site Admin
Posts: 23154
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by Tim Green »

michal_novomesky wrote: Tue Aug 31, 2021 8:15 am * IF_ISDEFAULT_PAGE works for every HTML page generated as index.html?

No, because index.html is not a topic in the standard skins. It is the main layout page that contains the iFrames in which the other pages are displayed. If you want to put something in the main layout page you don't need a condition like this at all. You just edit the Layout template in the skin in Configuration > Publishing Options > WebHelp > Layout.
(the default topic is not always selected in Table of Contents (represented by an icon) and the default topic is considered then as first item in TOC).
You should always define the default topic. Don't leave it undefined. In some cases leaving it undefined can cause problems.

Note that in the V3 and V4 skins in the Premium Pack index.html is a normal topic, because these skins do not use a layout page. There every topic contains the full layout, but only the first topic visited is opened. After that the content of the topics the user wants to browse to is replaced dynamically from compressed JSON copies, which is much faster than normal browsing. The new condition won't work in these skins because it will only have an effect if the first page the user browses to is the default topic, which is index.html.
* will be this condition a part of H&M documentation as well?
Yes, of course. It will be added in the next official update.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by michal_novomesky »

We use a tailored "Single Page responsive" skin with topic content for each .html page (including index.html), where TOC is in <iframe>.
We want to display FAQ only on the page that are marked as default, and only for help projects that want to have FAQs.
The solution you prepared for us is cleaner than adding <script src="faq.js"> for each .html page and trying to determine by document.location whether URL contains index.html

Pseudocode:

Code: Select all

<IF_ISDEFAULT_PAGE>
<IF_FAQ>
HTML CODE TO DISPLAY FAQ...
</IF_FAQ>
</IF_ISDEFAULT_PAGE>
<iframe src="<%HREF_CONTENT_PAGE%>" ...>
<%TOPIC_TEXT%>
User avatar
Tim Green
Site Admin
Posts: 23154
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: IF_DEFAULT_PAGE?

Unread post by Tim Green »

Hi Michal,

Very cool, that sounds like a great solution. 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Post Reply