-1

How to set up a variable on the root directory for the url link in ColdFusion?

I set up the variable on the root directory for the url link, appweb\instance.cfm:

<CFSCRIPT>
 ...
 ...     
  Application.MainLink = "http://www.ucdavis.edu/index.html";

</CFSCRIPT>

I have a file under appweb/costsharing/footer.cfm to use the variable for url link, but it doesn't work.

<br />
<br />
<div align="center">
<b>Need Help?  Visit the <a href="#Application.MainLink#" target=_blank>Cost    Sharing Help</a></b>
</div>
<br />
<br />
<CFInclude Template="../OnRequestEnd.cfm">

</body>
</html>

Any suggestion?

tigerpuzzle
  • 69
  • 2
  • 8
  • elaborate your question?? **set up a variable on the root directory** are you trying to call your file from other directory ? – RSSCE Nov 30 '15 at 19:28
  • Not call this file, but I need to reference the variable from the subdirectory. – tigerpuzzle Nov 30 '15 at 19:44
  • you need to reference `#Application.MainLink#" ` ?? any error ? – RSSCE Nov 30 '15 at 19:55
  • Yes, I need use the variable 'Application.MainLink' on subdirectory. When I click on 'Cost Sharing Help', it doesn't go to http://www.ucdavis.edu/index.cfm. It points to http://appweb/costsharing/#Application.Mainlink# – tigerpuzzle Nov 30 '15 at 20:11
  • how come it will go on "ucdavis.edu/index.cfm' if you are setting ` Application.MainLink = "http://www.ucdavis.edu/index.html";` it should go "http://www.ucdavis.edu/index.html" as you are defining. – RSSCE Nov 30 '15 at 20:52
  • Sorry, it was my typo. it should go '../index.html'. – tigerpuzzle Nov 30 '15 at 21:16
  • its fine did you check the answer ?? – RSSCE Nov 30 '15 at 21:21

2 Answers2

1

You can define.

<cfset Application.MainLink = "http://www.ucdavis.edu/index.html">
OR 
<cfset Application.MainLink = "http://www.ucdavis.edu/index.cfm">

If you want to point any sub-directory you can define in your application.cfc root directory for example:

<cfset application.rootDir = getDirectoryFromPath(getCurrentTemplatePath()) /> 

In your code you can use:

#application.rootDir#/appweb/costsharing/index.cfm

USE this for link

<a href="<cfoutput>#Application.MainLink#</cfoutput>" target=_blank>Cost Sharing Help</a>

RSSCE
  • 164
  • 6
1

I had the same issue, for some reason beyond my understanding you need to put http:// in front. I am aware of the late response but I am doing this for future people that will have the same issue. So this can be used:

<a href="http://#Application.MainLink#" target=_blank>
Dany
  • 47
  • 5