• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a way to convert HTML to Coldfusion?

New Here ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

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?

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation