Page 1 of 1

Conditional text based on variables?

Posted: Mon Feb 11, 2019 5:37 am
by oceanclub
Is there any way to display context depending on the value of a variable?

P.

Re: Conditional text based on variables?

Posted: Mon Feb 11, 2019 7:04 am
by ChoccieMuffin
Could you give a bit more context please? I'm not quite sure what you're trying to achieve.

Re: Conditional text based on variables?

Posted: Mon Feb 11, 2019 7:19 am
by oceanclub
ChoccieMuffin wrote:Could you give a bit more context please? I'm not quite sure what you're trying to achieve.
Hi there,

In this specific version, I have a variable called ElasticsearchVersion, which is the version of ES required by our software.

This works well in our topics: even in, say, links to their website, where I can use the variable in both the text and the URL of the hyperlink.

However in some instances, while my version variable is the major and minor version (ie, 5.2.2), the documentation links on their website include only the major version (ie, 5.2). So I was wondering if I could have multiple URLs, then hide/show them based on the value of the variable. I wanted to avoid having a condition tag for this since it would rarely if ever be used.

P.

Re: Conditional text based on variables?

Posted: Sun Sep 15, 2019 11:48 pm
by robdocsmith
Hi,

How about using two variables? One variable for the URL and one for the text. So if a target has the URL defined it gets turned into an appropriate link. If there is no URL defined for the target, just the variable with the text in it is displayed:

Topic contains:
<p>Software version: <a href="[%=Variables.URL%]"><MadCap:variable name="Variables.URL_Display_Text" /></a>.</p>

Target 1 defines
Variables.URL as ""
Variables.URL_Display_Text as "5.2.2"

Target 2 defines
Variables.URL as "http://www.theurllink.com/"
Variables.URL_Display_Text as "5.2"

Only the second target gets the link in the output.... Hmmmm just tested that and both get a link in the output, but only one resolves to an actual link. The other is underlined as per a link but doesn't link anywhere. If you're links aren't styled with underlines you might be able to get away with that...

Cheers,
Rob