• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Create a Variable within a Variable?

New Here ,
Sep 20, 2006 Sep 20, 2006

Copy link to clipboard

Copied

Hi,

I want to create a non-generic .cfm file which is created with <CFFILE>. The output of the file is below in the quotes. I am using <CFSAVECONTENT> to save this but the problem is CFML actually parses the variables rather than using it to store in a variable... I don't want the variables parsed until I display the variable created by <CFSAVECONTENT> (when we write the .cfm file.

I hope that makes sense? Thanks! :)

quote:


<!--- build section phrases --->
<CFSET sectionPhrase = "#FORM.title#, #FORM.subTitle#">
<CFSET metaKeywords = "#FORM.title#, #FORM.subTitle#">
<CFSET metaDesc = "#FORM.title#, #FORM.subTitle#, UK suppliers of cheap #FORM.title#.">


<!--- includes --->
<CFINCLUDE TEMPLATE="#REQUEST.baseWebURL#inc/header.cfm">
<CFINCLUDE TEMPLATE="#REQUEST.baseWebURL#inc/leftMenu.cfm">
<CFINCLUDE TEMPLATE="#REQUEST.baseWebURL#inc/ingredientShow.cfm">

TOPICS
Advanced techniques

Views

144

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2006 Sep 20, 2006

Copy link to clipboard

Copied

LATEST
Oliver,

If I understand you correctly, what you want is dynamic variable evaluation, and ColdFusion does it better than any language I've seen!

Instead of:
<!--- build section phrases --->
<CFSET sectionPhrase = "#FORM.title#, #FORM.subTitle#">
<CFSET metaKeywords = "#FORM.title#, #FORM.subTitle#">
<CFSET metaDesc = "#FORM.title#, #FORM.subTitle#, UK suppliers of cheap #FORM.title#.">


Try:
<!--- build section phrases --->
<CFSET sectionPhrase = "##FORM.title##, ##FORM.subTitle##">
<CFSET metaKeywords = "##FORM.title##, ##FORM.subTitle##">
<CFSET metaDesc = "##FORM.title##, ##FORM.subTitle##, UK suppliers of cheap ##FORM.title##.">


And then, to evaluate them use:

<CFOutput>
#Evaluate(DE(SectionPhrase))#
#Evaluate(DE(MetaKeywords))#
#Evaluate(DE(MetaDesc))#
</CFOutput>

I'm not sure if this is exactly what you want your code to do, but hopefully you can extract the principle of dynamic variables out of it, and use it to get it to do what you want.

HTH
Swift

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation