Skip to main content
Participant
April 4, 2013
Question

Is there a way to convert HTML to Coldfusion?

  • April 4, 2013
  • 1 reply
  • 1695 views

I have a site with hundreds of HTML pages that need to be converted to coldfusion in order to password protect my site. Is there an easy way to do this? Mass convert the files somehow?

This topic has been closed for replies.

1 reply

Inspiring
April 4, 2013

Since HTML and CFML are 2 different things (CFML generates HTML), the easiest way to do this is to do a massive extension change from .html to .cfm (this will make it so that when the page is requested, it is passed off to ColdFusion to be processed)

At that point, you can use the application.cfc to wrap the call to the requested page in <cfoutput> tags. A ColdFusion page could handle the file renaming.  Something like this (check it before you run it)

<cfdirectory

          name="htmlFiles"

          action="list"

          directory="#expandPath( '/absolute/path/to/root/html/folder' )#"

          filter="*.html"

          recurse="true"

          type="file" />

 

<cfloop query="htmlFiles">

 

          <cffile

                    action="rename"

                    source="#directory##name#"

                    destination="#directory##listFirst( name, '.' )#.cfm" />

 

</cfloop>

ERAepAuthor
Participant
April 4, 2013

Well, the problem is, this site has html files which are in subdirectories. For example folder1 has 3 html files and contains folder 2. Folder 2 contains folders 3 and 4, both of which have html files. Is there a way to set up the cfdirectory to look at all files in the entire site this way?

Thanks for your help!

Inspiring
April 4, 2013

It already is.  The RECURSE attribute was set to TRUE.  This means it will go down into all subfolders looking for .html files as well rather than just stay at the initial directory specified.