Variable within a variable

2008-12-27 Thread Maya MacDonald
How can you display a variable within a variable? 

I have a client who needs to control the content of all email notices that go 
out to their clients. 

Email notices have some dynamic content such as grabbing customer name or 
account details. The value of the email notice content is stored in a variable 
called #emailContent# and I would like it to have a value of something like 
this (where it contains varibles within itself): 

Dear #customer#, 

Email content email content...your account expires on #expiryDate#. 

However, when the variable #emailContent# is outputted within a CFMAIL tag the 
variables #customer# and #expiryDate# just get shown as is with the hash marks. 
How can I output the variables within the variable? 

Thanks! 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317147
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Variable within a variable

2008-12-27 Thread Seb Duggan
There's no simple way to do this (as far as I'm aware) in ColdFusion.

BlueDragon has a very useful function - Render() - which will parse  
the contents of a variable, exactly as you describe.

But on ColdFusion, I've always handled cases like this by having my  
templates as flat files to be included; the variables within them get  
processed as normal.


Seb

Seb Duggan
Web  ColdFusion Developer

e:  s...@sebduggan.com
t:  07786 333184
w:  http://sebduggan.com

On 27 Dec 2008, at 13:14, Maya MacDonald wrote:

 How can you display a variable within a variable?

 I have a client who needs to control the content of all email  
 notices that go out to their clients.

 Email notices have some dynamic content such as grabbing customer  
 name or account details. The value of the email notice content is  
 stored in a variable called #emailContent# and I would like it to  
 have a value of something like this (where it contains varibles  
 within itself):

 Dear #customer#,

 Email content email content...your account expires on #expiryDate#.

 However, when the variable #emailContent# is outputted within a  
 CFMAIL tag the variables #customer# and #expiryDate# just get shown  
 as is with the hash marks. How can I output the variables within the  
 variable?

 Thanks!


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317148
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Variable within a variable

2008-12-27 Thread Maya MacDonald
Seb,

Thank you for the reply.

I am not quite sure I am following how I would include this as a flat file?  

Thanks,
Devin 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317149
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Variable within a variable

2008-12-27 Thread David Low
Maya,

When you're setting up your initial variable, can't you do something
like cfset variables.emailMessage = Dear   variables.customerName
 chr(10)  chr(13)  Message here /

 - then you're combining the variables before you use them...

David


2008/12/27 Maya MacDonald devinpar...@hotmail.com:
 Seb,

 Thank you for the reply.

 I am not quite sure I am following how I would include this as a flat file?

 Thanks,
 Devin

 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317150
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Variable within a variable

2008-12-27 Thread Dominic Watson
Does evaluate do the trick?

cfmail...#Evaluate(emailContent)#/cfmail

Dominic

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317151
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Variable within a variable

2008-12-27 Thread Dominic Watson
On another note - I have done something similar for a client where
they could setup various email templates. What I did was to give them
a set of keys they could use in their email body that would be
replaced with the relevent data. The options I gave them were like:

[title],
[firstname],
[lastname],
 etc

Then when it came to sending the email I did a group of replace
statements on the template body:

cfset emailContent= Replace(emailContent, '[title]', user.title)/
cfset emailContent= Replace(emailContent, '[firstname]',
user.firstname)/ ... etc

Dominic

2008/12/27 Dominic Watson watson.domi...@googlemail.com:
 Does evaluate do the trick?

 cfmail...#Evaluate(emailContent)#/cfmail

 Dominic


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317152
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Variable within a variable

2008-12-27 Thread Maya MacDonald
Thanks Dominic I'll give that a try! 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317153
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Variable within a variable

2008-12-27 Thread Seb Duggan
Either:

1. Have a separate file with just the content of the email, including  
the variables you want replaced, and include it in your cfmail like  
this:

cfmail ...
cfinclude template=myemailtemplate.cfm /
/cfmail

or:

2. If your template text is in a database, you could generate a temp  
file on the fly with the template text in it, then include that file  
as above. I'm not sure what the performance implications of this would  
be, but you'd have to weigh that against how often the process is  
called. Alternatively, generate the appropriate flat file whenever the  
template is updated.

But I've also used Dominic's method of replaceing a [variable] token  
in the template using Replace().


Seb


Seb Duggan
Web  ColdFusion Developer

e:  s...@sebduggan.com
t:  07786 333184
w:  http://sebduggan.com

On 27 Dec 2008, at 13:38, Maya MacDonald wrote:

 Seb,

 Thank you for the reply.

 I am not quite sure I am following how I would include this as a  
 flat file?

 Thanks,
 Devin



Seb Duggan
Web  ColdFusion Developer

e:  s...@sebduggan.com
t:  07786 333184
w:  http://sebduggan.com



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317154
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Variable within a variable

2008-12-27 Thread Jason Durham
Assuming your email message is _not_ in the database, just use
cfsavecontent  and appropriately nested cfoutput.

cfsavecontent variable=emailContent
cfoutput
pDear #customer#:/p 
pPay your $(*ing bill already./p
/cfoutput 
/cfsavecontent

-Original Message-
From: Seb Duggan [mailto:s...@sebduggan.com] 
Sent: Saturday, December 27, 2008 10:59 AM
To: cf-talk
Subject: Re: Variable within a variable

Either:

1. Have a separate file with just the content of the email, including  
the variables you want replaced, and include it in your cfmail like  
this:

cfmail ...
cfinclude template=myemailtemplate.cfm /
/cfmail

or:

2. If your template text is in a database, you could generate a temp  
file on the fly with the template text in it, then include that file  
as above. I'm not sure what the performance implications of this would  
be, but you'd have to weigh that against how often the process is  
called. Alternatively, generate the appropriate flat file whenever the  
template is updated.

But I've also used Dominic's method of replaceing a [variable] token  
in the template using Replace().


Seb


Seb Duggan
Web  ColdFusion Developer

e:  s...@sebduggan.com
t:  07786 333184
w:  http://sebduggan.com

On 27 Dec 2008, at 13:38, Maya MacDonald wrote:

 Seb,

 Thank you for the reply.

 I am not quite sure I am following how I would include this as a  
 flat file?

 Thanks,
 Devin



Seb Duggan
Web  ColdFusion Developer

e:  s...@sebduggan.com
t:  07786 333184
w:  http://sebduggan.com





~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317165
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4