Skip to main content
Inspiring
May 2, 2012
Frage

storing dymanic content in the database

  • May 2, 2012
  • 1 Antwort
  • 469 Ansichten

I am trying to allow the user to create their own "reports" and I need them to be able to store content with variables names into the database.

for example

A user would type the following information into a multi-line text box and store that in a SQL database field.

Hello, #firstName#, Thank you for contacting us on #contactdate#.  If there is anything I can help you with, please contact me at #companyPhone#.

There would then be a page that would look like this:

<cfquery name="getContent" datasource="x">

select usercontent

from contenttable

where id = 1

</cfquery>

<cfquery name="getList" datasource="x">

select firstname, contactdate, email

from userlist

</cfquery>

<cfmail to="#email" from="sales@company.com" subject="Follow up" query="getList">

#getContent.usercontent#

</cfmail>

So basically, I want the  email to be compiled from the text that the user enters into the DB, and the variables populated with the correct info.

I've tried playing with the evaluate() and de() fields but I cant get on the right track.

If I use #evaluate(getcontent.usercontent)# I can get it to work, only using 1 variable.  I cant get it to work with the whole paragraph of text.

any help would be greatly appreciated.

steve

    Dieses Thema wurde für Antworten geschlossen.

    1 Antwort

    ifsteveAutor
    Inspiring
    May 2, 2012

    after more digging I found a solution that worked:

    <cffunction access="private" name="ConvertLinks" returntype="string">

     

              <cfargument name="theContent" type="string" required="yes">

       

        <cfset var theReturn=arguments.theContent>

       

         <!--- setup each field that may be used --->

        <Cfsavecontent variable="firstname">#firstname#</Cfsavecontent>

        <Cfsavecontent variable="contactdate">#contactdate#</Cfsavecontent>   

        <Cfsavecontent variable="email">#clinicianid#</Cfsavecontent>       

       

         <!--- replace each field that may be used, case sensative --->

        <Cfset theReturn=replace(theReturn,firstname,Evaluate(de(firstname)),"All")>

        <Cfset theReturn=replace(theReturn,contactdate,Evaluate(de(contactdate)),"All")>   

        <Cfset theReturn=replace(theReturn,email,Evaluate(de(email)),"All")>       

     

         <!--- return the usable value --->

              <cfreturn theReturn>

    </cffunction>

    and I call

    <cfoutput>#convertlinks(getContent.usercontent)# </cfoutput>

    on my page.