Use two different definitions of a variable in one topic

This forum is for all Flare issues not related to any of the other categories.
Post Reply
chuck_agari
Sr. Propeller Head
Posts: 225
Joined: Wed May 30, 2018 2:40 pm

Use two different definitions of a variable in one topic

Post by chuck_agari »

I have come across a situation that I cannot figure out how to easily solve.

In my project, which I use to develop content for (now) 3 products, I use a variable set. Several variables define variations on product names. In the targets for each product, I select the correct variable values.

I'm now writing a topic where, for the first time, I'm referencing two products, the product that I'm documenting in the topic and a different product. Naturally, I don't want static text. But I can't figure out how I'd use [ProductName] variable in the topic and have it refer to one value in one instance in the topic and a different value in a different instance in the topic. I don't think that this can be done--indeed, I dont' think it makes sense to allow. But I'm posting on the off chance that I'm wrong and I missed some esoteric functionality.

I can see only a couple of ways around this:
- Make separate product-specific variable definitions, which kind of defeats the purpose of variables (and makes the variable list longer).
- Juast leave the reference as static text, and if on the unlikely chance we ever change product names (again) do a project-wide search on find any product names that were not variablized.
Psider
Propellus Maximus
Posts: 816
Joined: Wed Jul 06, 2011 1:32 am

Re: Use two different definitions of a variable in one topic

Post by Psider »

I think you can do this by putting the variable in a snippet, then choosing which definition to use for a single instance of a snippet. I haven't tried this myself, but it sounds like what you want to do.

https://help.madcapsoftware.com/flare20 ... ippets.htm

Although, rereading, if you want both instances of the variables to (ah-hem) vary depending on the output, you might need to get more complicated.

Thought experiment. You want the second product to vary depending on the target you are generating.

For the main product reference, use the variable as is. This will vary depending on the target you're generating.
For the other second product, use a snippet containing the variable. 1. Insert the snippet. 2. tag with the target condition. 3. select the appropriate definition for that target. 4. Repeat for each target.

Not sure if this works and/or is too complicated, but something for you to at least try. I'm sure someone else currently using Flare will jump in. :)
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Use two different definitions of a variable in one topic

Post by NorthEast »

chuck_agari wrote:- Make separate product-specific variable definitions, which kind of defeats the purpose of variables (and makes the variable list longer).
This is what I do, when I refer to a specific product.

It doesn't defeat the purpose of variables. For some of our products, the name changed 3 times in 5 years, so I was glad I only had to change a single variable rather than several hundred references.
Or sometimes I can start work on documentation before the product name has been decided, so it's handy in those situations too.
chuck_agari
Sr. Propeller Head
Posts: 225
Joined: Wed May 30, 2018 2:40 pm

Re: Use two different definitions of a variable in one topic

Post by chuck_agari »

Dave Lee wrote:
chuck_agari wrote:- Make separate product-specific variable definitions, which kind of defeats the purpose of variables (and makes the variable list longer).
This is what I do, when I refer to a specific product.

It doesn't defeat the purpose of variables. For some of our products, the name changed 3 times in 5 years, so I was glad I only had to change a single variable rather than several hundred references.
Or sometimes I can start work on documentation before the product name has been decided, so it's handy in those situations too.
Ick.

Right now, I have, for example

- ProductName {long}
- ProductName (short}

When we added a new product, I just added a new definition to these variables. When we change product names, I just change the definition in these variables.

It sound like you're suggesting I need

- Product1ProductName )long)
- Product1ProductName (short)
- Product2ProductName {long}
- Product2ProductName {short)
and now
- Product3ProductName {long}
- Product3ProductName {short}
and because we're bifurcating a current product, I'll also need
- Product4ProductName {long}
- Product4ProductName {short)
and if/when we add to out product portfolio
- Product5ProductName (long)
- Product5ProductName (short)
etc., etc., etc.

Each with either one (for the products we only sell ) or two (for the products we allow a partner to sell and rebrand) definitions.

Rather than like I have it now, with me just adding (or changing) definitions as the product line expands (or changes). This latter is, I think, the true power of how variables are implemented in Flare.
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: Use two different definitions of a variable in one topic

Post by NorthEast »

Well, I don't know your project, but from what you said, it sounded like the references to product names are fixed - i.e. when you have a reference to Product2, then isn't that reference is always going to be to Product2?
chuck_agari
Sr. Propeller Head
Posts: 225
Joined: Wed May 30, 2018 2:40 pm

Re: Use two different definitions of a variable in one topic

Post by chuck_agari »

Dave Lee wrote:Well, I don't know your project, but from what you said, it sounded like the references to product names are fixed - i.e. when you have a reference to Product2, then isn't that reference is always going to be to Product2?
No. Currently, I have just to product name definitions, on "short" and one "long." Each has multiple definitions, and for each target, which is for a specific product (or sometimes a subset, like my review targets), I select the definition I want for that target.

In thinking about what I want to do, I'd like a "local override," sort of like in CSS, where for the instance of a variable, I'd like to say "use this definition for this instance only, no matter what the target says the definition should be." I'm guessing that's not an option, which means that I'll not be able to keep my set of variables streamlined.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Use two different definitions of a variable in one topic

Post by ChoccieMuffin »

Chuck, would SNIPPET VARIABLES work for you? The help is here:

http://help.madcapsoftware.com/flare201 ... ippets.htm
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
chuck_agari
Sr. Propeller Head
Posts: 225
Joined: Wed May 30, 2018 2:40 pm

Re: Use two different definitions of a variable in one topic

Post by chuck_agari »

ChoccieMuffin wrote:Chuck, would SNIPPET VARIABLES work for you? The help is here:

http://help.madcapsoftware.com/flare201 ... ippets.htm
Hmmm....I think it would. It adds a level of complexity, in that I think I'd have to have both snippets and variables named "ProductName(short)" and "ProductName(long)," but if I understand this functionality correctly, I just create a snippet that includes only the product name variable, and then if I want to reference a different product in a target, I use the snippet instead of the variable and override the value in the snippet.

Thanks!
chuck_agari
Sr. Propeller Head
Posts: 225
Joined: Wed May 30, 2018 2:40 pm

Re: Use two different definitions of a variable in one topic

Post by chuck_agari »

This works, but I seem to have found a bug. (What's new?)

I created 2 snippets, ProductNameLong and ProductNameShort. In each, I inserted the appropriate variable. In my content, I added the snippet where I wanted a different value that then value used in the target.

Here's where the bug it. In the instances where I was using it, the default definition was what I wanted. I opened the snippet settings to see what the variable definition was, saw that it was the value that I wanted, and closed the dialog. But when I built the target PDF, the target value was used.

I went back to one topic and opened the snippet settings again. I changed the definition to a different one and closed the settings dialog. The hew definition appeared in the topic. I opened the snippet settings again and set the variable definition back to what I wanted (and here I found a 2nd bug, the background of the drop-down was all black, making the text unreadable, so it's a good thing I knew the position in the list of the definition I wanted), and closed the snippet settings dialog again. I did another build, and this time, I got the value that I wanted.

I guess with great power comes not only great responsibility, but many bugs.
Post Reply