Varaibles in Hyperlinks

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.

Varaibles in Hyperlinks

Postby GCotgreave on Thu Mar 19, 2009 3:06 am

Hi,
Not having much luck inserting a system variable within a hyperlink, and wondered if anyone can point out where I am going wrong.

I would basically like a very simple error report message at the bottom of each page, logically it would be;

<a href="http://www.myhomesite.co.uk/help/errorreport.php?mcvariable:System.SourceFile">Tell us about a problem on this page</a>

Where magically the mcvariable:System.SourceFile is replaced uniquely for each page.

I've looked at "User Interface Elements - How to Use Each One > Inserting Variables into Topics" which implies that a link can contain a variable but isn't clear how to achieve this via the UI. I end up with the call being made without any variable substitution.

I have tried defining my own variable with a value
<pre>http://www.myhomesite.co.uk/help/errorreport.php?mcvariable:System.SourceFile</pre>
and then inserting this as a variable on the page mcvariable:MyVaraibles.Feedbacklink but that doesn't seem to work either.

I believe the end result could all be inserted in a snippet and then placed appropriately on each page.

Thanks in advance.
GCotgreave
Jr. Propeller Head
 
Posts: 8
Joined: Mon Apr 24, 2006 2:30 am
Location: UK

Re: Varaibles in Hyperlinks

Postby KevinDAmery on Thu Mar 19, 2009 5:59 am

I'm not clear what the problem is exactly: are you having problems inserting the variable, or is it not being applied properly when you build your output?
Until next time....
Image
Kevin Amery
Certified MAD for Flare
KevinDAmery
Propellus Maximus
 
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Varaibles in Hyperlinks

Postby GCotgreave on Thu Mar 19, 2009 7:10 am

Hi
A bit of both really...

1) Should I insert a hyperlink and in the link add the mcvariable:System part or
2) Generate a MyVariable containing the hyperlink and mcvariable:System element and insert the variable in the document.

Should <ctrl>leftclick on allow the resultant element from above to be activated or will the replacement only work in a finalised and published project? (<ctrl>leftclick at present it opens a hyperlink without doing the replacement)
GCotgreave
Jr. Propeller Head
 
Posts: 8
Joined: Mon Apr 24, 2006 2:30 am
Location: UK

Re: Varaibles in Hyperlinks

Postby KevinDAmery on Thu Mar 19, 2009 7:33 am

GCotgreave wrote:Hi
A bit of both really...

1) Should I insert a hyperlink and in the link add the mcvariable:System part


This is how I would do it. Usually I create the hyperlink first, then insert the variable inside it. I haven't tried with system variables (only with "normal" variables) but the principle should be the same.

or
2) Generate a MyVariable containing the hyperlink and mcvariable:System element and insert the variable in the document.


I don't know if variables containing link text will work - but in any case, since variables are defined in the target you may end up with the same link in each topic by doing this. You could try it, but I think it's likely to be more problematic.

Should <ctrl>leftclick on allow the resultant element from above to be activated or will the replacement only work in a finalised and published project? (<ctrl>leftclick at present it opens a hyperlink without doing the replacement)


You would only see it in the output. When you build the output the variable should be replaced with the appropriate text, creating a valid link. Until then, it contains the variable code so the link won't go anywhere that exists.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
KevinDAmery
Propellus Maximus
 
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Varaibles in Hyperlinks

Postby GCotgreave on Thu Mar 19, 2009 9:47 am

Thanks for your help so far,
KevinDAmery wrote:
GCotgreave wrote:Hi

This is how I would do it. Usually I create the hyperlink first, then insert the variable inside it. I haven't tried with system variables (only with "normal" variables) but the principle should be the same.


But I'm not quite there, We are getting correct substitution, but not quite in the correct place. I think I'm being a bit dense on inserting the variable. The variable is ending up in the wrong part of the tag ;
When I look at the code in Flare
<a+> Feedback <MadcapVaraible/> [Sysytem.SourceFile] </a>
Whereas it should be inside the <a+> component which is href = http://www.myhomesite.co.uk/help/form.php?filename= inorder to be placed at the end of the href and not as part of the link's text component. Flare doesn't seem to want to allow me to edit the <a+> component directly . Any more clues as to where I'm going wrong?
GCotgreave
Jr. Propeller Head
 
Posts: 8
Joined: Mon Apr 24, 2006 2:30 am
Location: UK

Re: Varaibles in Hyperlinks

Postby KevinDAmery on Thu Mar 19, 2009 9:52 am

Ahhh.... I missed that. I usually place variables to change the text of the link, not the code. Hm, not sure if that will work after all. This would require putting the variable tag inside the a link tag, which may not be valid XML.

In any case, I wouldn't use the "code view" to check this. Code view is, IMO, next to useless. Instead, if you need to get into the code I would open the topic in a text editor (Flare has a built in one, or you can use an external one if you prefer). Just make sure you back up the topic before making the change, because as I mentioned this may not be valid XML so the topic may not open in the XML editor after making the change.
Until next time....
Image
Kevin Amery
Certified MAD for Flare
KevinDAmery
Propellus Maximus
 
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Varaibles in Hyperlinks

Postby Craig.Prichard on Fri Aug 20, 2010 12:30 pm

What is the answer to the question, "How do you place a Flare system variable, e.g. the filename, within the anchor tag"? I embed an email link on every page and would like to include the filename as part of the Subject. Everything else about the link works as expected. I just can't get the filename in there.
Craig.Prichard
Propeller Head
 
Posts: 59
Joined: Sat Dec 10, 2005 8:06 pm
Location: Calgary, AB Canada

Re: Varaibles in Hyperlinks

Postby GCotgreave on Tue Aug 31, 2010 3:28 am

In the end one of our web developers came up with a solution.
We publish HTML help shipped with our product, so that it looks the same regardless of the OS platform they choose. At the bottom of each help page is a link which takes them back to a dynamic webpage on the company server. This is pre-filled with topic and file name information allowing us to see exactly which help page they are commenting on.

This link could easily be the email that you mention
Craig.Prichard wrote:I embed an email link on every page and would like to include the filename as part of the Subject.



This is basically a hack around the issue in Flare not correctly replacing information in links.

Step 1 = Declare a CSS Class called footer and add it to the cell/link you want to modify

Step 2 = Add the Flare variables to the link you wish to use in the footer, each variable will be output in a span tag.

Step 3 = Add a custom JS file that contains the code to resolve the variables into the required link we called ours footer.js

When the script is loaded it automatically runs the containing function which resolves the span tags into the required link.

Below is the content of footer.js which generates our link back to the website.

Code: Select all
// JavaScript Document
2
3createFooter();
4
5function createFooter() {
6 var theFooter;
7 var theFooterList;
8 var theSpanList;
9 var i, j;
10 var varA = "";
11 var varB = "";
12 var strHTM = "";
13
14 theFooterList = document.getElementsByTagName("a");
15
16 for (i=0; i < theFooterList.length; i++) {
17 theFooter = theFooterList[i];
18 if (theFooter.className == "footerlink") {
19 theSpanList = theFooter.getElementsByTagName("span");
20 varA = theSpanList[0].innerHTML;
21 varB = theSpanList[1].innerHTML;
22 break;
23 }
24 }
25
26// strHTM += "<a href=\"http://www.mycompanywebsite.co.uk/pages/help/form.php?topicname=" + varA + "&filename=" + varB + "\" title=\"\" target=\"_NEW\">Click Here</a>";
27 theFooter.innerHTML = "click here";
28 theFooter.href = "http://www.mycompanywebsite.co.uk/pages/help/form.php?topicname=" + varA + "&filename=" + varB;
29 theFooter.title = "click here to comment on our help system";
30 theFooter.target = "_new";
31}
GCotgreave
Jr. Propeller Head
 
Posts: 8
Joined: Mon Apr 24, 2006 2:30 am
Location: UK

Re: Varaibles in Hyperlinks

Postby kel322 on Tue Aug 08, 2017 11:39 am

Hi there,
I know this is years later, but I thought I would post another solution. Our group has been trying to accomplish the same thing, and we didn't think about system variables until after a few days of racking our brains.

We have a hyperlink on a master page that goes to a survey that gathers feedback regarding our help files. We wanted to know what page the user was on when he/she clicked on the link to get to the survey.

Anyway, through trying different things, we found that if you use the following syntax, your hyperlink will show the information in the system variable: [=%System.Title%] (or whatever variable that you want to capture).

Our hyperlink that is on the masterpage looks something like this:
Code: Select all
<a href="http://surveylink.com/feedback/?product=ourproduct&amp;type=help&amp;id=[%=System.Title%]&amp;version=2.00>
.

When the user clicks the link and is taken to the survey page, the link in the url window looks like this:
Code: Select all
http://surveylink.com/feedback/?product=ourproduct&amp;type=help&amp;id=UsingOurProudct&amp;version=2.00
.

Hope that saves some headaches for someone!
kel322
Propeller Head
 
Posts: 20
Joined: Tue Jan 03, 2017 12:56 pm

Re: Varaibles in Hyperlinks

Postby phillipkent on Fri Mar 16, 2018 4:06 am

I can confirm that using '[%=VARIABLESET.VARIABLENAME%]' works great in Flare 2017 r3.
phillipkent
Jr. Propeller Head
 
Posts: 2
Joined: Fri Feb 02, 2018 9:32 am

Re: Varaibles in Hyperlinks

Postby devjoe on Thu Apr 05, 2018 2:00 pm

In recent versions, this format used to be documented in the Flare help, but it seems it's fallen out in 2017r3 help.
The formats still work. When you are using a variable someplace other than in literal text elements of a page:
  • If the variable makes up the entire text of its entry (for instance, an entire TOC entry or the entire destination of a link), enter the text mcvariable:VariableSet.VariableName
  • Otherwise, type it this way: [%=VariableSet.VariableName%]
devjoe
Sr. Propeller Head
 
Posts: 308
Joined: Thu Jan 23, 2014 1:43 pm

Re: Varaibles in Hyperlinks

Postby BrianAtInTouchHealth on Tue Jul 02, 2019 4:30 pm

Hi,

We use the following variables to create PDF file names in our PDF targets:

Code: Select all
[%=Cover Variables.P/N:%] [%=Cover Variables.Product Name%] [%=Cover Variables.PDFGuideTitle%]


What I've been trying to do in our HTML5 help but without any luck is to use these variables in hyperlinks. For example, I've added the following link to our master page:

Code: Select all
<div class="Note">Download the <img src="../Images/PDF_24.png" style="mc-thumbnail: none;width: 24px;height: auto;" /> <a href="../../PDFs/[%=Cover Variables.P/N:%] [%=Cover Variables.Product Name%] [%=Cover Variables.PDFGuideTitle%].pdf" target="_blank">[%=Cover Variables.P/N:%] [%=Cover Variables.Product Name%] [%=Cover Variables.PDFGuideTitle%]</a>.</div>


While the link text comes out correctly the link itself does not. From the posts above it sounds like this should work but it doesn't Any ideas?

Thanks,
Brian
Flare :flare: + Analyzer :analyzer: 2019, Capture :capture: 7.0, Mimic :mimic: 8.1
BrianAtInTouchHealth
Propeller Head
 
Posts: 27
Joined: Thu Dec 27, 2018 10:35 am
Location: Goleta (Santa Barbara County), CA

Re: Varaibles in Hyperlinks

Postby Nita Beck on Tue Jul 02, 2019 5:42 pm

I think the problem might be that you are putting the link on the masterpage. The link is relative, so when Flare tries to resolve it for each individual topic that is associated with that masterpage, the relative link that begins "<a href="../../PDFs/" (excluding the quotes I've used to frame this example) might work for some but not all topics. The relative link might need to be "../../../PDFs/" for some topics, while for others it would need to be "../PDFs/", depending on the location of each topic relative to where the PDFs are stored.

I recently achieved using variables for PDF filenames in hyperlinks myself, and I know it works, but I was putting the links into individual topics, not on the masterpage. Additionally, I wrote an article for the team I'm supporting to explain that if they wanted to set up similar links in other topics, they'd need to make sure that the relative path to the PDFs would be correct for each of those individual topics.
Nita
Image
Content Strategist / Information Architect / Flare Consultant: http://beck-communications.com
Manager, Rochester Flare User Group: http://www.facebook.com/RochesterFlareUserGroup
Nita Beck
Senior Propellus Maximus
 
Posts: 3286
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Varaibles in Hyperlinks

Postby BrianAtInTouchHealth on Tue Jul 02, 2019 5:52 pm

Nita,

Wow! Thank you for the quick response! :D And yes, you are 100% correct -- I'm trying to put this in the master page so the link is always available. I was able to get a PDF link in a master page to work but I did it by hard coding it, not using a relative link. Oh well, back to Square One.

Thanks,
Brian
Flare :flare: + Analyzer :analyzer: 2019, Capture :capture: 7.0, Mimic :mimic: 8.1
BrianAtInTouchHealth
Propeller Head
 
Posts: 27
Joined: Thu Dec 27, 2018 10:35 am
Location: Goleta (Santa Barbara County), CA


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 5 guests