Conditional text based on variables?

This forum is for Single-Sourcing your Flare content to multiple outputs.
Post Reply
oceanclub
Sr. Propeller Head
Posts: 277
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

Conditional text based on variables?

Post by oceanclub »

Is there any way to display context depending on the value of a variable?

P.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Conditional text based on variables?

Post by ChoccieMuffin »

Could you give a bit more context please? I'm not quite sure what you're trying to achieve.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
oceanclub
Sr. Propeller Head
Posts: 277
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

Re: Conditional text based on variables?

Post 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.
robdocsmith
Sr. Propeller Head
Posts: 247
Joined: Thu May 24, 2018 3:11 pm
Location: Queensland, Australia

Re: Conditional text based on variables?

Post 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
Post Reply