This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C05AED.88A591B8
Content-Type: text/plain;
charset="iso-8859-1"
take a look at this...
It's in the beginning stages, and its a piece of a custom tag that generates
a form on the fly, but it does what you want it to do without all of the
hassle and replacing. All you have to do is put two pound signs on the vars
that you would like to be executed.
<cfset r_HTML = r_HTML & "
<html>
<head>
<title>" & stForm.FormTitle & "</title>
</head>
<body>
<cfoutput>
<form action='##cgi.script_name##?Process=##NowWhat##<cfif NowWhat IS
'Edit'>&##IDName##=##IDValue##</cfif>' method='POST'
enctype='multipart/form-data'>
<table width='" & stForm.FormWidth & "' cellspacing='" &
stForm.FormCellSpacing & "' cellpadding='" & stForm.FormCellPadding & "'
border=0>
<tr><td colspan=2>" & stForm.FormTitleFont & stForm.FormTitle & "
</font></td></tr>
<tr><td colspan=2>" & stForm.InstructionsFont& stForm.Instructions &
"</font> </td></tr>
">
<cfset r_rowStart ="<tr><td bgcolor='" & stForm.bgColorHeaders & "'>" &
stForm.HeadersFont >
<cfset r_rowMid ="</td><td bgcolor='" & stForm.bgColorFields & "'>" &
stForm.FieldsFont >
<cfset r_rowEnd = "</td></tr>">
<cfloop from="1" to="#ArrayLen(aFormItems)#" index="x">
<cfset r_HTML = r_HTML & r_rowStart & stForm.Headers[x] & r_rowMid &
aFormItems[x] & r_rowEnd>
</cfloop>
<cfset r_HTML = r_HTML & "
<tr><td colspan=2 align=center valign=middle><input type=submit name=submit
value='" & stForm.SubmitTextValue & "'>" & NL & NL &
" <input type=reset name=reset value='Reset'></td></tr>
</table>
</cfoutput>
</body>
</html>">
<cftry>
<cffile action="WRITE" output="#r_HTML#" nameconflict="overwrite"
file="#stForm.FormSaveLocation#" >
<cfcatch type="Any">
The File did not get written properly.
<cfoutput>
<P>#CFCATCH.message#</P>
<P>Caught an exception, type = #CFCATCH.TYPE# </P>
</cfoutput>
<cfexit>
</cfcatch>
</cftry>
HTH,
Robert Hinojosa
Senior WebDeveloper
[EMAIL PROTECTED]
www.hencie.com
972-671-0011 ext.284
-----Original Message-----
From: j p [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 30, 2000 9:37 AM
To: CF-Talk
Subject: CFFILE - writing a CF template REDUX
Maybe I mis-communicated my delima, here it is in code...
I want to write a CF template using CFFILE - I know what the template will
look like, but need some variables resolved.
The only way I have foud to work is:
1) Set var to the entire contents of the page
2) use the < > " to replace these characters
3) Use a special character (I use ` ) to replace the pound signs
4) keep poound signs where a dynamic var will be resolved
5) Do a series of Replace() functions on this var before I pass it to CFFILE
THERE HAS TO BE A BETTER WAY????
Example:
Section A - is the actual page code I want to generate, with all character
that cause a problem replaces with something else. This is needed beacuse a
<, >, or " inside a CFSET (or inside teh CFFILE) will cause the tag to
fail.
Section B - Replaces these characters with their real character
Section C - Writes the file
<!--- SECTION 'A' --->
<cfset PageCode ="
<html>">
<body bgcolor="#variables.myBGColor#">
some page text
`variables.SomeVar`
</body>
</html>
">
<!--- SECTION 'B' --->
<cfset ValidationError = Replace(Variables.ValidationError, "`","##",
"All")>
<cfset ValidationError = Replace(Variables.ValidationError, "<","<",
"All")>
<cfset ValidationError = Replace(Variables.ValidationError, ">",">",
"All")>
<cfset ValidationError = Replace(Variables.ValidationError, ""","""",
"All")>
<!--- SECTION 'C' --->
<cffile action="WRITE"
file= C:\...\Page.cfm"
addnewline="Yes"
output="#Variables.PageCode#">
QUESTION: Is these a better way to do this???
More efficient? Better code?
jp
____________________________________________________________________________
_________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
------_=_NextPart_001_01C05AED.88A591B8
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12">
<TITLE>RE: CFFILE - writing a CF template REDUX</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>take a look at this...</FONT>
</P>
<P><FONT SIZE=3D2>It's in the beginning stages, and its a piece of a =
custom tag that generates a form on the fly, but it does what you want =
it to do without all of the hassle and replacing. All you have to =
do is put two pound signs on the vars that you would like to be =
executed.</FONT></P>
<BR>
<P><FONT SIZE=3D2><cfset r_HTML =3D r_HTML & "</FONT>
<BR><FONT SIZE=3D2><html></FONT>
<BR><FONT SIZE=3D2><head></FONT>
<BR><FONT SIZE=3D2><title>" & stForm.FormTitle & =
"</title></FONT>
<BR><FONT SIZE=3D2></head></FONT>
<BR><FONT SIZE=3D2><body></FONT>
<BR><FONT SIZE=3D2><cfoutput></FONT>
<BR><FONT SIZE=3D2><form =
action=3D'##cgi.script_name##?Process=3D##NowWhat##<cfif NowWhat IS =
'Edit'>&##IDName##=3D##IDValue##</cfif>' method=3D'POST' =
enctype=3D'multipart/form-data'></FONT></P>
<P><FONT SIZE=3D2><table width=3D'" & stForm.FormWidth =
& "' cellspacing=3D'" & stForm.FormCellSpacing & =
"' cellpadding=3D'" & stForm.FormCellPadding & =
"' border=3D0></FONT></P>
<P><FONT SIZE=3D2><tr><td colspan=3D2>" & =
stForm.FormTitleFont & stForm.FormTitle & " =
</font></td></tr></FONT>
<BR><FONT SIZE=3D2><tr><td colspan=3D2>" & =
stForm.InstructionsFont& stForm.Instructions & =
"</font> </td></tr></FONT>
<BR><FONT SIZE=3D2>"></FONT>
</P>
<P><FONT SIZE=3D2><cfset r_rowStart =3D"<tr><td =
bgcolor=3D'" & stForm.bgColorHeaders & "'>" =
& stForm.HeadersFont > </FONT>
<BR><FONT SIZE=3D2><cfset r_rowMid =3D"</td><td =
bgcolor=3D'" & stForm.bgColorFields & "'>" =
& stForm.FieldsFont ></FONT>
<BR><FONT SIZE=3D2><cfset r_rowEnd =3D =
"</td></tr>"></FONT>
<BR> =
=20
<BR><FONT SIZE=3D2><cfloop from=3D"1" =
to=3D"#ArrayLen(aFormItems)#" =
index=3D"x"></FONT>
<BR> <FONT SIZE=3D2><cfset =
r_HTML =3D r_HTML & r_rowStart & stForm.Headers[x] & =
r_rowMid & aFormItems[x] & r_rowEnd> </FONT>
<BR><FONT SIZE=3D2></cfloop></FONT>
</P>
<P><FONT SIZE=3D2><cfset r_HTML =3D r_HTML & "</FONT>
<BR><FONT SIZE=3D2><tr><td colspan=3D2 align=3Dcenter =
valign=3Dmiddle><input type=3Dsubmit name=3Dsubmit =
value=3D'" & stForm.SubmitTextValue & "'>" =
& NL & NL & "&nbsp;&nbsp;&nbsp;<input =
type=3Dreset name=3Dreset =
value=3D'Reset'></td></tr></FONT></P>
<P><FONT SIZE=3D2></table></FONT>
<BR><FONT SIZE=3D2></cfoutput></FONT>
<BR><FONT SIZE=3D2></body></FONT>
<BR><FONT SIZE=3D2></html>"></FONT>
</P>
<P><FONT SIZE=3D2><cftry></FONT>
<BR> <FONT =
SIZE=3D2><cffile action=3D"WRITE" =
output=3D"#r_HTML#" nameconflict=3D"overwrite" =
file=3D"#stForm.FormSaveLocation#" ></FONT>
<BR><FONT SIZE=3D2><cfcatch type=3D"Any"></FONT>
<BR> <FONT SIZE=3D2>The File =
did not get written properly. </FONT>
<BR> <FONT =
SIZE=3D2><cfoutput></FONT>
<BR><FONT SIZE=3D2> =
<P>#CFCATCH.message#</P></FONT>
<BR><FONT SIZE=3D2> <P>Caught an exception, =
type =3D #CFCATCH.TYPE# </P></FONT>
<BR> <FONT =
SIZE=3D2></cfoutput></FONT>
<BR> <FONT =
SIZE=3D2><cfexit></FONT>
<BR><FONT SIZE=3D2></cfcatch></FONT>
<BR><FONT SIZE=3D2></cftry></FONT>
</P>
<P><FONT SIZE=3D2>HTH,</FONT>
</P>
<P><FONT SIZE=3D2>Robert Hinojosa </FONT>
<BR><FONT SIZE=3D2>Senior WebDeveloper </FONT>
<BR><FONT SIZE=3D2>[EMAIL PROTECTED] </FONT>
<BR><FONT SIZE=3D2>www.hencie.com </FONT>
<BR><FONT SIZE=3D2>972-671-0011 ext.284 </FONT>
</P>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: j p [<A =
HREF=3D"mailto:[EMAIL PROTECTED]">mailto:[EMAIL PROTECTED]=
</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Thursday, November 30, 2000 9:37 AM</FONT>
<BR><FONT SIZE=3D2>To: CF-Talk</FONT>
<BR><FONT SIZE=3D2>Subject: CFFILE - writing a CF template REDUX</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>Maybe I mis-communicated my delima, here it is in =
code...</FONT>
</P>
<P><FONT SIZE=3D2>I want to write a CF template using CFFILE - I know =
what the template will </FONT>
<BR><FONT SIZE=3D2>look like, but need some variables resolved.</FONT>
</P>
<P><FONT SIZE=3D2>The only way I have foud to work is:</FONT>
<BR><FONT SIZE=3D2>1) Set var to the entire contents of the page</FONT>
<BR><FONT SIZE=3D2>2) use the &lt; &gt; &quot; to replace =
these characters</FONT>
<BR><FONT SIZE=3D2>3) Use a special character (I use ` ) to replace the =
pound signs</FONT>
<BR><FONT SIZE=3D2>4) keep poound signs where a dynamic var will be =
resolved</FONT>
<BR><FONT SIZE=3D2>5) Do a series of Replace() functions on this var =
before I pass it to CFFILE</FONT>
</P>
<P><FONT SIZE=3D2>THERE HAS TO BE A BETTER WAY????</FONT>
</P>
<P><FONT SIZE=3D2>Example:</FONT>
<BR><FONT SIZE=3D2>Section A - is the actual page code I want to =
generate, with all character </FONT>
<BR><FONT SIZE=3D2>that cause a problem replaces with something else. =
This is needed beacuse a </FONT>
<BR><FONT SIZE=3D2><, >, or " inside a CFSET (or =
inside teh CFFILE) will cause the tag to </FONT>
<BR><FONT SIZE=3D2>fail.</FONT>
</P>
<P><FONT SIZE=3D2>Section B - Replaces these characters with their real =
character</FONT>
</P>
<P><FONT SIZE=3D2>Section C - Writes the file</FONT>
</P>
<BR>
<P><FONT SIZE=3D2><!--- SECTION 'A' ---></FONT>
<BR><FONT SIZE=3D2><cfset PageCode =3D"</FONT>
<BR><FONT SIZE=3D2>&lt;html&gt;"></FONT>
<BR><FONT SIZE=3D2>&lt;body =
bgcolor=3D&quot;#variables.myBGColor#&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>some page text</FONT>
</P>
<P><FONT SIZE=3D2>`variables.SomeVar`</FONT>
</P>
<P><FONT SIZE=3D2>&lt;/body&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;/html&gt;</FONT>
<BR><FONT SIZE=3D2>"></FONT>
</P>
<P><FONT SIZE=3D2><!--- SECTION 'B' ---></FONT>
<BR><FONT SIZE=3D2><cfset ValidationError =3D =
Replace(Variables.ValidationError, "`","##", =
</FONT>
<BR><FONT SIZE=3D2>"All")></FONT>
<BR><FONT SIZE=3D2><cfset ValidationError =3D =
Replace(Variables.ValidationError, =
"&lt;","<", </FONT>
<BR><FONT SIZE=3D2>"All")></FONT>
<BR><FONT SIZE=3D2><cfset ValidationError =3D =
Replace(Variables.ValidationError, =
"&gt;",">", </FONT>
<BR><FONT SIZE=3D2>"All")></FONT>
<BR><FONT SIZE=3D2><cfset ValidationError =3D =
Replace(Variables.ValidationError, =
"&quot;","""", </FONT>
<BR><FONT SIZE=3D2>"All")></FONT>
</P>
<P><FONT SIZE=3D2><!--- SECTION 'C' ---></FONT>
<BR><FONT SIZE=3D2><cffile action=3D"WRITE"</FONT>
<BR> =
<FONT SIZE=3D2>file=3D =
C:\...\Page.cfm"</FONT>
<BR> =
<FONT =
SIZE=3D2>addnewline=3D"Yes"</FONT>
<BR> &=
nbsp; <FONT =
SIZE=3D2>output=3D"#Variables.PageCode#"></FONT>
</P>
<BR>
<P><FONT SIZE=3D2>QUESTION: Is these a better way to do this???</FONT>
<BR><FONT SIZE=3D2>More efficient? Better code?</FONT>
</P>
<P><FONT SIZE=3D2>jp</FONT>
</P>
<P><FONT =
SIZE=3D2>_______________________________________________________________=
______________________</FONT>
<BR><FONT SIZE=3D2>Get more from the Web. FREE MSN Explorer =
download : <A HREF=3D"http://explorer.msn.com" =
TARGET=3D"_blank">http://explorer.msn.com</A></FONT>
</P>
<P><FONT =
SIZE=3D2>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</FONT>
<BR><FONT SIZE=3D2>Structure your ColdFusion code with Fusebox. Get the =
official book at <A HREF=3D"http://www.fusionauthority.com/bkinfo.cfm" =
TARGET=3D"_blank">http://www.fusionauthority.com/bkinfo.cfm</A></FONT>
</P>
<P><FONT SIZE=3D2>Archives: <A =
HREF=3D"http://www.mail-archive.com/[email protected]/" =
TARGET=3D"_blank">http://www.mail-archive.com/[email protected]/=
</A></FONT>
<BR><FONT SIZE=3D2>Unsubscribe: <A =
HREF=3D"http://www.houseoffusion.com/index.cfm?sidebar=3Dlists" =
TARGET=3D"_blank">http://www.houseoffusion.com/index.cfm?sidebar=3Dlists=
</A></FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C05AED.88A591B8--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists