Solved

using cfif tag within cfsavecontent not allowing me to write file

Posted on 2013-06-14
2
422 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
Comment Utility
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 15

Accepted Solution

by:
myselfrandhawa earned 500 total points
Comment Utility
@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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now