Solved

using cfif tag within cfsavecontent not allowing me to write file

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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