Something like this. I haven't tested this code as I've hacked it out of
another project and tweaked it a bit to match what you want. The
PageContent variable would of course come from your database. You could
change the markers to be anything you want by tweaking the regular
expression: "\[\[[^]]+]]"
Make sense? :-)
<cfset PageContent = "Lorem ipsum dolor sit amet, consectetuer
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis
nostrud [[myinclude.cfm]] exerci tation ullamcorper suscipit lobortis
nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor
in hendrerit in vulputate velit esse molestie consequat, vel illum
dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore
te feugait nulla facilisi.">
<cfset NotDone = "TRUE">
<cfset StartingPoint = 1>
<cfloop condition="#NotDone#">
<cfset NextInclude = REFindNoCase("\[\[[^]]+]]", PageContent,
StartingPoint, "TRUE")>
<cfif NextInclude.Pos[1]>
<cfset FileName = Mid(PageContent, NextInclude.Pos[1] +
2, NextInclude.Len[1] - 4)>
<cfsavecontent variable="IncludedContent">
<cftry>
<cfinclude template="#FileName#">
<cfcatch>
!Include
"<cfoutput>#FileName#</cfoutput>" failed!
</cfcatch>
</cftry>
</cfsavecontent>
<cfset PageContent = Insert(IncludedContent,
RemoveChars(PageContent, NextInclude.Pos[1], NextInclude.Len[1]),
NextInclude.Pos[1] - 1)>
<cfelse>
<cfset NotDone = "FALSE">
</cfif>
<cfset StartingPoint = NextInclude.Pos[1]>
</cfloop>
> -----Original Message-----
> From: Jillian Carroll [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 25 July 2002 10:58 a.m.
> To: CF-Talk
> Subject: RE: Processing CF Code from a DB
>
>
> That would be great Matthew, I'd appreciate some code!
>
> -----Original Message-----
> From: Matthew Walker [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 24, 2002 4:41 PM
> To: CF-Talk
> Subject: RE: Processing CF Code from a DB
>
>
> You could write a copy from the database to the server each time you
> want to run it then cfinclude that copy. Or you could keep a set of
> files on the server that is a duplicate of the database content. This
> would be more efficient and easier to code.
>
> Or another approach would be to use some kind of marker in your text
> instead of the cfinclude. You could put for example:
>
> Lorem ipsum dolor sit amet, consectetuer [[includes/myinclude.cfm]]
> adipiscing elit, sed diam nonummy nibh euismod
>
> then use regular expressions to find each one of these [[]] and
> cfinclude the file. I am using a very similar technique on several
> current projects. If you want more detail, ask. I can supply
> some code.
>
>
> Regards,
> Matthew Walker
> /*
> Easier, smarter forms:
> http://www.matthewwalker.net.nz/inform2
> */
>
>
>
> > -----Original Message-----
> > From: Jillian Carroll [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, 25 July 2002 9:51 a.m.
> > To: CF-Talk
> > Subject: Processing CF Code from a DB
> >
> >
> > I've got a problem here... I am storing content in a database
> > that is being
> > retrieved when a visitor hits the page. 90% of the code is
> > static, it is
> > just the body of the page coming from the DB.
> >
> > WELL... I have a user that wants to store some CF code (in
> > the form of an
> > include) in the DB. When he does this, it stores tickety
> > boo... but it
> > doesn't process.
> >
> > I assume it has to do with some order of processing done by
> > CF... is there
> > any way I can make this work?
> >
> > --
> > Jillian
> >
> >
>
>
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists