?
Solved

using cfif tag within cfsavecontent not allowing me to write file

Posted on 2013-06-14
2
Medium Priority
?
470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 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