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
Jr. Propeller Head
 
Posts: 6
Joined: Tue Jan 03, 2017 12:56 pm


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 3 guests