Solved

using cfif tag within cfsavecontent not allowing me to write file

Posted on 2013-06-14
2
434 Views
Last Modified: 2013-07-15
Hi, I am trying to write a file depending on certain conditions. When I place the condition in it won't write the file.
This is possible:

<cfsavecontent variable="testing">
<cfif test1 eq 'certainstring’>
<cfinclude template="../a.cfm">
</cfif>
<cfif test2  eq ‘anotherstring'>
<cfinclude template="../ b.cfm">
<cfelseif test2  eq somethingdifferent'>      
<cfinclude template="../c">
</cfif>
  </cfsavecontent>
0
Comment
Question by:armanbena
2 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 39249479
Your code doesn't show writing to a file, you are creating a variable called "testing" that contains whatever is in file a, b or c.

after the end of your cfsavecontent, you can show the contents by doing:
<cfdump var="#testing#">

In general, there isn't anything wrong with your sample code (except for type-o's, but since it's obviously not the real code, it's not worth debugging).    I suggest posting your real code for real help.
0
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 39250913
@gdemaria: Correct,

Just put dump and also use <cfoutput>#testing#</ccfoutput>

to check your rendered result

You can always do like this

<cffile action="write" file="#ExpandPath(a.txt)#" output="#trim(testing)#">

That way you can se the results

Make sure you included files does not have coldfusion issues
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question