Another approach is using replace(). SO in your DB store
"Welcome $:1 to the end of the Internet"
Then use a function call to wrap things
fetchWelcomeText( cookie.username )
fetchWelcomeText() would look something like
<cfquery name="myQuery" datasource="dataSource">
select myText from welcome_statements
</cfquery>
<cfreturn replace( myQuery.myText, "$:1", arguments.username ) />
This approach is a bit more flexible, you can say easily switch between
cookies and sessions or spit out the same text for some other name.
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
On Tue, Jun 30, 2009 at 5:07 PM, Fennell, Mark P. <[email protected]> wrote:
> I figured it out, but if you have a more elegant solution, I'm open to
> suggestions.
> Here's my current solution.
> <cfquery name="myQuery" datasource="dataSource">
> select myText from welcome_statements
> </cfquery>
> <cfoutput>#evaluate("#de(myQuery.myText)#")#</cfoutput>
> Thanks.
> mf
>
>
> -----Original Message-----
> From: Fennell, Mark P.
> Sent: Tuesday, June 30, 2009 4:57 PM
> To: '[email protected]'
> Subject: CF in the database?
>
>
> Greetings all,
> I'm trying to figure out a way in CF7 to store CF variables in the database
> to be selected out later and evaluated just like regular CF variables.
>
> For example, and I know this is a stupid example, but it's simple and makes
> the point, let's assume I have a database table called welcome_statements
> and it has a single column that contains string data such as "Welcome,
> #cookie.user_name#." In my home.cfm file, I write a query like select
> my_text from welcome_statements and have a CFOUTPUT block like
> <cfoutout>#myQuery.my_text#</cfoutput>. I've tried using various
> combinations of evaluate() and de() and replacing the # in the database with
> something that is replaced on evaluation in the query and in the cfoutput.
> All to no avail.
>
> I know you're wondering, "Why would you want to do a fool thing like that?"
> Well, I'm trying to figure out how to allow users to write form letters or
> MS Word-like mail-merge documents. I imagine it would be simpler in CF than
> to write some manner of database function/procedure which is why I'm asking
> for your assistance.
> Many thanks in advance.
> mf
>
>
> mark fennell
> athens regional medical center
> athens, ga
>
> -----------------------------------------------------------------------
> This email is intended only for the named recipient(s). It may contain
> information that is proprietary, confidential or otherwise prohibited from
> disclosure. If you are not the named addressee, you are not authorized to
> read, print, retain, copy or disseminate this message or any part of it. If
> you have received this message in error, please reply immediately by email
> or telephone me at 706-475-4357 and delete all copies of the message.
> -----------------------------------------------------------------------
>
>
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, manage your profile @
> http://www.acfug.org?falogin.edituserform
>
> For more info, see http://www.acfug.org/mailinglists
> Archive @ http://www.mail-archive.com/discussion%40acfug.org/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>
>