Solved

Coldfusion - New Line without using <br>

Posted on 2013-06-06
5
806 Views
Last Modified: 2013-06-06
Hello experts
I have a function to create a part of my htaccess file.
I'm using the following code:
<cffunction name="fwriteurlcategories" access="private" returntype="void">
  <!--- Get information from categories table--->
  <cfset var getcategories = fcategories()>
  <cfoutput query="geturlrwcategories">
   <cfset newline = "ReWriteRule ^#newlinkalias#$ index.cfm?action=viewcategory&category=#categoryid#">
   <cffile action = "append" file="#variables.catalogpath#.htaccess" output="#newline#" addnewline="yes" charset="utf-8">
  </cfoutput>
</cffunction>

Open in new window


This way i'm adding each row in a new line in the htaccess file.
Is there any way to 1) create the content with all the rewriterules2) and append it to the document?
I tried to use the query inside a cfsavecontent but i can't get the rewriterules in new lines.

Any help?
0
Comment
Question by:Panos
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39226984
If I'm understanding correctly, the problem is new lines are o/s dependent.  

* On windows it's: chr(13) & chr(10)  and Unix its:  chr(10)
* If you have createObject access, you can use System.getProperty("line.separator") instead.

So you can use cfsavecontent .. but it preserves all white space, so you may need to put it all on the same line. Something like this:

Edit - Add final write to disk
...
<cfset var content = "">
<cfset var newLine = chr(13)&chr(10)>
<cfsavecontent variable="content">
 <cfoutput query="geturlrwcategories">ReWriteRule ^#newlinkalias#$ index.cfm?action=viewcategory&category=#categoryid##newLine#</cfoutput>
</cfsavecontent>
<!--- overwrite existing file --->
<cffile action="write" file="#variables.catalogpath#.htaccess" output="#newline#" charset="utf-8">

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 39227276
Thank you agx.
It is working
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 39227278
regards
panos
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39227459
Correction for the archives.  That very last line:

     <cffile action="write" file="#variables.catalogpath#.htaccess"
            output="#newline#" charset="utf-8">

should be this instead:

     <cffile action="write" file="#variables.catalogpath#.htaccess"
            output="#content#" charset="utf-8">
0
 
LVL 2

Author Comment

by:Panos
ID: 39227573
Thank you agx.
I have allready correct this.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

10 Experts available now in Live!

Get 1:1 Help Now