Conditional parts in linked topics

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

Post Reply
Tobias Escher
Posts: 202
Joined: Mon Dec 28, 2015 7:32 pm

Conditional parts in linked topics

Unread post by Tobias Escher »

I have a topic that has an explanation of features within a toggle.
I now need to show or hide individual parts of this topic within other topics depending on local variables in these "target topics".

So, example:
I have topic EXPLANATION which has ten lines of text.
I then have topics ProductA, ProductB and ProductC.
Each of these 3 topics needs to display individual lines of text depending on local variables.
So if for example LOCAL_Y is true, then a certain line from the EXPLANATION topic is shown. If it is false, then not.
I need to do this with several dozen lines and variables, so it is not an option to have multiple EXPLANATION topics because it would mean making changes to dozens of very similar topics all the time.

How can I use variables as a condition? I can only seem to use builds as a condition.

EDIT: So essentially what I am looking for is:
If VARIABLE = True THEN insert this text ELSE do nothing.
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Conditional parts in linked topics

Unread post by Martin Wynne »

Hi Tobias,

What is the problem with creating custom builds for this?

Alternatively if it is HTML-based output you can do a lot of conditional stuff using #MERGE.

For example: if file xyx.txt exists, insert text, or insert <!-- to comment-out existing text.

regards,

Martin.
Tobias Escher
Posts: 202
Joined: Mon Dec 28, 2015 7:32 pm

Re: Conditional parts in linked topics

Unread post by Tobias Escher »

Hi Martin,

as far as I know custom builds only work on a global basis, not on a per topic basis.
The aforementioned 3 topics ProductA, ProductB and ProductC are always included in the same document. It is the content of these 3 topics that would need to change based on the topic variables set in these topics.

My EXPLANATION topic itself imports several dozen snippets. This EXPLANATION topic is inserted in dozens of other topics and variables should determine which snippets are displayed in which topic. Build do not work for that because one cannot set builds per topic, only globally. Variables however can be set per topic, but seemingly can not be used as conditions.

Unfortunately the output is PDF, so merge does not work.
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Conditional parts in linked topics

Unread post by Martin Wynne »

Hi Tobias,

You can use builds for that. Just create a custom build, put conditional tags round the text, then tick or untick the build in the list when publishing. Ditto for as many builds as you need.

Unless I'm missing something? :?

regards,

Martin.
Tobias Escher
Posts: 202
Joined: Mon Dec 28, 2015 7:32 pm

Re: Conditional parts in linked topics

Unread post by Tobias Escher »

Yes, but I need multiple variations of this EXPLANATION topic in the same export.
This topic is inserted on several dozen pages and it needs to have different content everywhere. I can say "only publish this line if build Y is active", but then it will do it on every instance where this topic is inserted. I need "insert this line in topic A, but not in topic B". Of course I could manually insert the individual topics as needed, but it would be MUCH quick to do it with variables.
There about 100 topics and about 12-15 "variations" of the EXPLANATION topic. But all these variations will be in the same exports, so it is not multiple exports!
User avatar
julio
Posts: 118
Joined: Wed May 28, 2008 12:06 am
Location: Porto Alegre, RS - Brasil
Contact:

Re: Conditional parts in linked topics

Unread post by julio »

I do not understand when you talk about every instance where this topic is inserted. By instance you mean product? Because earlier you say that product A, B, and C are inserted on a single document. If you provide a more concrete example then maybe it becomes clearer what you are trying to achieve.
Tobias Escher wrote:Yes, but I need multiple variations of this EXPLANATION topic in the same export.
This topic is inserted on several dozen pages and it needs to have different content everywhere. I can say "only publish this line if build Y is active", but then it will do it on every instance where this topic is inserted. I need "insert this line in topic A, but not in topic B". Of course I could manually insert the individual topics as needed, but it would be MUCH quick to do it with variables.
There about 100 topics and about 12-15 "variations" of the EXPLANATION topic. But all these variations will be in the same exports, so it is not multiple exports!
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Conditional parts in linked topics

Unread post by Martin Wynne »

Hi Tobias,

Properly you need to pass a build parameter into a snippet when linking to it. I can't see any way to do that in PDF.

But if you put the actual text into the topic variable by nesting another variable within it, I think you would get the required result. Create the base variable and leave it empty. And another 15 variables with the required line(s) to nest into it where required.

regards,

Martin.
Last edited by Martin Wynne on Fri Jul 22, 2016 6:27 pm, edited 1 time in total.
Tobias Escher
Posts: 202
Joined: Mon Dec 28, 2015 7:32 pm

Re: Conditional parts in linked topics

Unread post by Tobias Escher »

Ok, I'll try to describe as good as I can.

I have a project that describes the content of several products. Let's call it "Product Guide". This product Guide describes Product A, Product B and Product C (in reality it is about 50 products).
Product A -C are based on a common technology that offers a number of features. Let's say 5 (in reality it is several dozen).

Product Guide now has a section for every Product A to C. These product pages are largely identical and extensively use placeholders for stuff like ProductName, ProductSize, etc...
These product pages also have a list of features. Product A has features 1-5. Product B has features 1-4 and Product C has features 1, 2 and 5.
Every product page (every product has its own topic) contains user-defined variabled for Feature 1 to 5 that can be True or False. If a variable is true, its corresponding feature description should be shown. If it is false, then not.

Of course I could now manually insert snippets of the different features. With 3 products and a max of 5 features this would be easy and that is what I do now. But I ultimately need several dozen features for 50 products that NEED to be in correct order, etc...

So using variables ("only show that line if variable X is true) would save a huge lot of time. In a perfect world I would use the very same content for every product page with what's displayed changing based on whether variables are true or false.

I can't do it with builds because builds are global and cannot be set per topic.

I hope that was clear(er)...


Martin: Great idea, but unfortunately the content changes daily :( Copy/Paste insteas of linking would mean having to redo it on dozens of topics pretty much daily.
User avatar
Martin Wynne
Posts: 2656
Joined: Mon May 12, 2003 3:21 pm
Location: West of the Severn, UK

Re: Conditional parts in linked topics

Unread post by Martin Wynne »

Tobias Escher wrote:Martin: Great idea, but unfortunately the content changes daily :( Copy/Paste insteas of linking would mean having to redo it on dozens of topics pretty much daily.
Hi Tobias,

The good news is that a redefined topic variable gets passed into a linked snippet. I just tested it to find out. Came as a surprise. :)

The bad news of course is that you are restricted to plain text this way, as far as I can see. No formatting or links within the text.

Martin.
User avatar
julio
Posts: 118
Joined: Wed May 28, 2008 12:06 am
Location: Porto Alegre, RS - Brasil
Contact:

Re: Conditional parts in linked topics

Unread post by julio »

So your scenario is the following:

Code: Select all

Product Guide
  Product A
    Feature 1 OK
    Feature 2 OK
    Feature 3 OK
    Feature 4 OK
    Feature 5 OK
  Product B
    Feature 1 OK
    Feature 2 OK
    Feature 3 OK
    Feature 4 OK
    Feature 5 NO
  Product C
    Feature 1 OK
    Feature 2 OK
    Feature 3 NO
    Feature 4 NO
    Feature 5 OK
Maybe you should think in the opposite direction, create a build called NO_FEATURE, or something like that, and always use it when compiling the product guide. In Product A, do not use this build, as all features are available. In Product B, use it after Feature 4. In Product C, use it after Feature 2 and before Feature 5.
Tobias Escher wrote:Ok, I'll try to describe as good as I can.

I have a project that describes the content of several products. Let's call it "Product Guide". This product Guide describes Product A, Product B and Product C (in reality it is about 50 products).
Product A -C are based on a common technology that offers a number of features. Let's say 5 (in reality it is several dozen).

Product Guide now has a section for every Product A to C. These product pages are largely identical and extensively use placeholders for stuff like ProductName, ProductSize, etc...
These product pages also have a list of features. Product A has features 1-5. Product B has features 1-4 and Product C has features 1, 2 and 5.
Every product page (every product has its own topic) contains user-defined variabled for Feature 1 to 5 that can be True or False. If a variable is true, its corresponding feature description should be shown. If it is false, then not.

Of course I could now manually insert snippets of the different features. With 3 products and a max of 5 features this would be easy and that is what I do now. But I ultimately need several dozen features for 50 products that NEED to be in correct order, etc...

So using variables ("only show that line if variable X is true) would save a huge lot of time. In a perfect world I would use the very same content for every product page with what's displayed changing based on whether variables are true or false.

I can't do it with builds because builds are global and cannot be set per topic.

I hope that was clear(er)...


Martin: Great idea, but unfortunately the content changes daily :( Copy/Paste insteas of linking would mean having to redo it on dozens of topics pretty much daily.
User avatar
julio
Posts: 118
Joined: Wed May 28, 2008 12:06 am
Location: Porto Alegre, RS - Brasil
Contact:

Re: Conditional parts in linked topics

Unread post by julio »

I am so sorry, when I said always use it when compiling the product guide, I meant never use it when compiling the product guide, that is, never on a command prompt or task, only on the list of features.

[quote="julio"]So your scenario is the following:

Code: Select all

Product Guide
  Product A
    Feature 1 OK
    Feature 2 OK
    Feature 3 OK
    Feature 4 OK
    Feature 5 OK
  Product B
    Feature 1 OK
    Feature 2 OK
    Feature 3 OK
    Feature 4 OK
    Feature 5 NO
  Product C
    Feature 1 OK
    Feature 2 OK
    Feature 3 NO
    Feature 4 NO
    Feature 5 OK
Maybe you should think in the opposite direction, create a build called NO_FEATURE, or something like that, and always use it when compiling the product guide. In Product A, do not use this build, as all features are available. In Product B, use it after Feature 4. In Product C, use it after Feature 2 and before Feature 5.
User avatar
Tim Green
Site Admin
Posts: 23157
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Conditional parts in linked topics

Unread post by Tim Green »

Hi Tobias,
So using variables ("only show that line if variable X is true) would save a huge lot of time. In a perfect world I would use the very same content for every product page with what's displayed changing based on whether variables are true or false.
You can't use variables for this. The only thing you could do is put the text you want to include in the variables and edit them on a per-topic basis, but that would be just as much work as doing it manually on a per-topic basis.
I can't do it with builds because builds are global and cannot be set per topic.
I'm afraid that's the way it is at the moment. What you need for this are per-topic builds or their equivalent, and those aren't available. No matter which way you look at it, you can't change that. Your only real option here is to use a larger number of snippets for your alternative texts and/or a larger number of build options.
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 parts in linked topics

Unread post by Martin Wynne »

Tim Green wrote:Your only real option here is to use a larger number of snippets for your alternative texts and/or a larger number of build options.
Hi Tim,

I've discovered that re-defined topic variables are propagated into linked snippets. :)

So providing each of his options can be described in a single line of plain text, Tobias could create a single snippet containing a list of pre-defined variables.

Then in the calling topic, any lines not wanted can be omitted from the topic, and the linked snippet, by re-defining them empty, or containing only a space, in the topic variables. This should significantly reduce the work needed on each topic.

Presumably this could go further, and such re-defined variables would be propagated into sub-snippets linked from a snippet?

regards,

Martin.
Tobias Escher
Posts: 202
Joined: Mon Dec 28, 2015 7:32 pm

Re: Conditional parts in linked topics

Unread post by Tobias Escher »

Unfortunately the individual sections are fairly complex with toggles, etc... and can not be realized with plain text variables.
I've pondered this long and hard and the only solution that does not require more work than just typing the same content several dozen times would be variable conditions. This does not seem to be possible... :(
Post Reply