Conditional output within the same build or format

HM5 served us well, now its time has come and it has been replaced... If you have HM5 questions, please post them here.

Moderators: Alexander Halser, Tim Green

Post Reply
Alexey Zhebel
Posts: 38
Joined: Tue Jun 07, 2011 10:03 am

Conditional output within the same build or format

Unread post by Alexey Zhebel »

Output format is CHM.
I would like to have two SEPARATE topics (with unique IDs) in my output, that have mostly similar text except for two words. I know I can just create two separate topics, but 99% of their content can be reused.

So, for instance, I want Topic_A to have:
<text> A.

And Topic_B to have:
<text> B.

All in THE SAME output.

Please, suggest a way to do this.
Alexey Zhebel
Posts: 38
Joined: Tue Jun 07, 2011 10:03 am

Re: Conditional output within the same build or format

Unread post by Alexey Zhebel »

I thought of one way:
1. Create a snippet topic with <text>.
2. Create Topic_A with <text> inserted as a snippet followed by word A.
3. Create Topic_B with <text> inserted as a snippet followed by word B.

This could work OK for one snippet, but if I want topics to be something like:
<text1> A/B <text2> A/B <text3>

I would have to create and maintain three snippet files, each of which would break in the middle of a sentence...
User avatar
Tim Green
Site Admin
Posts: 23189
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Conditional output within the same build or format

Unread post by Tim Green »

Hi Alexey,

It's much easier to use the Conditional Text tool for this. First define one or two conditions in Configuration > Common Properties > Custom Builds. If one of your options is the "standard" then you can get away with just one condition.

Let's say this condition is "ALTERNATE". Then you would use the Conditional Text tool ("IF" icon in Write > Insert Object) to insert the following tags for the text and the alternate version:

IF ALTERNATE Text Version One ELSE Text Version Two END

Then when you publish your CHM you would select ALTERNATE in the Include Options to produce a CHM with version one, and deselect it to produce a CHM with version two. 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.
Alexey Zhebel
Posts: 38
Joined: Tue Jun 07, 2011 10:03 am

Re: Conditional output within the same build or format

Unread post by Alexey Zhebel »

Thanks, Tim.
But that would produce TWO outputs (two CHM files). I need to have ONE output (i.e., just one CHM file) which would contain TWO topics that share almost all content, except for several words.

I don't think H&M has the ability to have alternate versions of similar text within the same output. The conditions only work when creating alternative versions in different outputs. I am trying to find a workaround for this or maybe I am just missing an obvious feature?

As for your suggestion, I could actually do that, create two CHM files using conditional output and then generate a third one which would include the first two CHMs.
User avatar
Tim Green
Site Admin
Posts: 23189
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Conditional output within the same build or format

Unread post by Tim Green »

Alexey Zhebel wrote:But that would produce TWO outputs (two CHM files). I need to have ONE output (i.e., just one CHM file) which would contain TWO topics that share almost all content, except for several words.
Ah, sorry, I missed that. Then snippets would be the easier solution, that's correct... 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.
Alexey Zhebel
Posts: 38
Joined: Tue Jun 07, 2011 10:03 am

Re: Conditional output within the same build or format

Unread post by Alexey Zhebel »

And its not possible to reuse specific parts of a topic's content? Only topics as a whole (by placing alternative TOC entries) or the full content of a topic (by inserting snippets)...

I believe this is a feature widely used within DITA. Since H&M is built with DITA in mind, is it possible that reusing parts of a topic will be added as a feature in the future?
User avatar
Tim Green
Site Admin
Posts: 23189
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Conditional output within the same build or format

Unread post by Tim Green »

Hi Alexey,

Snippets don't have to be a full topic! They can just be two words if you want, or even a single letter. And with Help & Manual 6 you can now insert snippets inline, so they can be merged into an existing paragraph. To save a small snippet, just select the text in the editor you want to use in the snippet and then select Save Snippet in Project > Manage Topics > File. When inserting the XML snippet file, make sure that you DEselect the "Snippet begins a new paragraph" option to insert it inline. Done. :)

If you're working in Help & Manual 5 you can't use inline snippets, there each snippet must be a minimum of one full paragraph.
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
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Conditional output within the same build or format

Unread post by Martin Wynne »

Alexey Zhebel wrote:but if I want topics to be something like:
<text1> A/B <text2> A/B <text3>

I would have to create and maintain three snippet files, each of which would break in the middle of a sentence...
Hi Alexey,

No, you can do it all with one overall snippet and text variables.

Create the required number of text variables and insert them in the snippet where you require different words.

Create the topics and insert the snippet in each one.

You can then override the value of the variables in each topic. Add the variables to the topic in the Topic Options, then double-click on the values to edit them for each topic.

regards,

Martin.
Alexey Zhebel
Posts: 38
Joined: Tue Jun 07, 2011 10:03 am

Re: Conditional output within the same build or format

Unread post by Alexey Zhebel »

Martin, that's brilliant! I totally forgot about the topic variables. It looks like that it should do the trick.
Post Reply