Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

template variable

Status
Not open for further replies.

Lotruth

Programmer
Joined
May 2, 2001
Messages
133
Location
US
I need a variable that contains the name of the current template. I need a form on application.cfm that recalls the current template, so I need a variable that I can put into the action attribute of this form so that it can be used on all pages. Thanks for your help.
 
GetCurrentTemplatePath() - Returns the fully specified path of the template that contains the call to this function.

you can use this to return the template name:

ListLast(GetCurrentTemplatePath(), "\") Sylvano
dsylvano@hotmail.com
 
Another question. When you reload a page, it re-sends all of information again. How can I get a reload button on my application.cfm page that also sends an additional parameter?
 
if page is reloaded by using browser reload button, you hava to change the value stored in the href.history object; u can do that with JavaScript;

if u use custom button to reload the page u can add parameter with ListAdd() function:

<button blah, blah.... onclick=&quot;JavaScript:reload('thisPage.cfm?#cgi.query_string#&newparam=whatever');&quot; Sylvano
dsylvano@hotmail.com
 
if page is reloaded by using browser reload button, you hava to change the value stored in the href.history object; u can do that with JavaScript;

if u use custom button to reload the page u can add write JavaScript function that will send the user to the same page with a new param:

<button blah, blah.... onclick=&quot;JavaScript:reload('thisPage.cfm?#cgi.query_string#&newparam=whatever');&quot; Sylvano
dsylvano@hotmail.com
 
Im still struggling with this. What I want is a form with a select list that I can put on the application.cfm page. The submit button should refresh the current page and send the selection to application.cfm simultaneously. With all the help you have given me so far I still cant figure this out. Thanks for sticking with me.
 
It occur to me from your last post that you might have misunderstand the cf application framework;

first, you cannot put 'form with a select list' on the application.cfm page; the application.cfm is typically used to name the application and other state management through <cfapplication>, default variables and global conastants such as datasource names, and absolute file paths for image and file libraries, custom error handling for general exceptions using <cferror>, default style settings such as fonts or colors using the local or request scope, and application-wide security code.
presentation code such as HTML and JavaScript should not be placed in the application.cfm.

second, you do not have to specify the location of the application.cfm in the submit button in order to send the selection to the application.cfm file; the application.cfm is ALWAYS executed whenever any cf application page is called; the application server will check the page's local directory for an application.cfm file. if one doesn't exists, the server will look in the parent directory, and up the directory tree until it either finds an application.cfm file or reaches the root directory of the hard drive.
if application.cfm file is found it is automatically included at the top of the code template and executed first. if there is no application.cfm file, the template page executes as per normal.

so, long story short, you can refresh the current page if you submit it to the current location:

form action=&quot;#ListLast(CGI.SCRIPT_NAME, '/')#?#CGI.QUERY_STRING#&quot;...

and don't worry about the application.cfm, if exists - it will be executed.

hope this help

S. Sylvano
dsylvano@hotmail.com
 
This is page1.cfm...

<form action=&quot;page2.cfm&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;tek&quot; value=&quot;tips&quot;>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>

This is page2.cfm...

<CFQUERY NAME=&quot;ProjData&quot; DATASOURCE=&quot;ds&quot;>
SELECT * FROM projects
</cfquery>
<FORM action=&quot;#ListLast(CGI.SCRIPT_NAME, '/')#?#CGI.QUERY_STRING#&quot; method=&quot;post&quot;>
<TABLE Border=&quot;1&quot;><tr>
<TD ALIGN=&quot;left&quot;><b>Project:
<SELECT NAME=&quot;ProjectID&quot;>
<OPTION VALUE=&quot;&quot;>
<cfoutput query=&quot;Projdata&quot;>
<OPTION VALUE=&quot;#ProjectID#&quot;>#ProjectID#
</cfoutput>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Switch&quot; name=&quot;button&quot;></SELECT>
</TD></TR></TABLE>
</form>

You are viewing project #form.projectid# and tek is #tek#.


When I click on [switch] it sends the selected #projectid# fine, but even with #CGI.QUERY_STRING#, it does not resend #tek#. Thanks for helping.

Also this is what I get at the end of the url after I click [switch]...

/crsp2.CFM#ListLast(CGI.SCRIPT_NAME,%20'/')#?#CGI.QUERY_STRING#

Is cgi.query_string supposed to show the actual string? Placing it in outputs doesnt help.
 
when you click [switch] THE FORM and specified fields are submitted; to make the &quot;tek&quot; variable available on the template where the form is being submitted to, you have to add it to the form as a one of it's fields on the page2.cfm:

when this is what you get as output:
/crsp2.CFM#ListLast(CGI.SCRIPT_NAME,%20'/')#?#CGI.QUERY_STRING#

it means that you did not enclosed the variables within the <cfoutput> tags:
<FORM action=&quot;<cfoutput>#ListLast(CGI.SCRIPT_NAME, '/')#?#CGI.QUERY_STRING#</cfoutput>&quot; method=&quot;post&quot;>

<input type=&quot;hidden&quot; name=&quot;tek&quot; value=&quot;<cfoutput>#tek#</cfoutput>&quot;>
Sylvano
dsylvano@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top