Solved

using cfif tag within cfsavecontent not allowing me to write file

Posted on 2013-06-14
2
426 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 15

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

17 Experts available now in Live!

Get 1:1 Help Now