Displaying HTMl stored in a database

Hi there,
I have started using ColdFusion again after a break of many many years, so I’m as rusty as anything.

Quick question.
I have a table that stores the HTML-tagged content between body tags. It is for the narrative documentation of a science project ( a bit like Wikipedia articles). I am using cffile
action=“write” to create a static HTML page for each article.

How do I get the HTML tags to be outputted by ColdFusion? I have tried both HTMLEditFormat() and HTMLCodeFormat, and neither.

The CFML files execute fine, but the displayed content is stripped of any HTML content that was in the database table.

#Article#

Many thanks
Mike Peters
New Zealand

1 Like

*whistles look fellas, another one!

In all seriousness, welcome back to the fold! :hugs: You’re going to love modern CF, I think…

but on to your question:

The CFML files execute fine, but the displayed content is stripped of any HTML content that was in the database table.

This sounds like one of two possibilities:

  1. You have enablecfoutputonly enabled, which means only content between <cfoutput></cfoutput> tags is rendered to the browser. See cfsetting Code Examples and CFML Documentation
  2. There’s some sort of HTML sanitization going on when you echo the variable into the “print buffer”, if that’s the right term.

I initially thought #1, reading your post, but now I’m leaning towards #2 based on your mention of HTML tags from the database table.

Hard to say without more details and/or code examples of the HTML, where/how it’s fetched, and how it is rendered.

Hi Michael

Thanks for your suggestions. Everything else works fine. CF is great!
I prefer the older tag-based syntax.

Here is a simplified version of the code

RenderContent.cfm
Stores a list of templates to use

<cfsetting enablecfoutputonly="yes">
  <cfoutput>
   <cfloop query="qryDisplayContent_Sort_AZ>">
     <cfinclude template="_include/#qryDisplayContent_Sort_AZ.DisplayContent#.cfm">
   </cfloop>
  </cfoutput>
<cfsetting enablecfoutputonly="no">

In this case #qryDisplayContent_Sort_AZ.DisplayContent#.cfm = DisplayArticle.cfm

DisplayArticle.cfm
The template displays an article written in HTML and stored as a database record.

<cfsetting enablecfoutputonly="yes">
  <cfoutput>
    <h1>#SomeArticleHeading#</h1>
    #SomeArticleContent#
  </cfputput>
<cfsetting enablecfoutputonly="no">

Any help appreciated
Mike Peters

Problem fixed. The static file generator is working 100%
Coldfusion is very fast
A wee silly mistake :grinning:

Mike