开发者

coldfusion using cfoutput with a variable in a variable name

I've got multiple files that have are using the same template cfm files

I have chunks of content of the pages in a template file content.cfm that I can retrieve through various variable names : content_home content_contact title_home title_contact

I'd like to have an intermediary template file that can call the content_#id# and title_#id# based on the provided id.

the id is defined with the template in开发者_JS百科 home.cfm and contact.cfm

The issue I'm having is that I cannot reference a variable using a variable as part of the name such as #content_#id##


I don't quite understand the question (or indeed, that you're asking a question ;-)

However are you just asking whether in parser.cfm you can do this:

<cfinclude template="content_#page#.cfm">

?

Well: yes you can. Try it!

BTW, I concur with the person who suggested you don't reinvent the wheel. Have a look at FW/1. It'll do all this stuff (and a lot more) for you.


Abstracting from the purpose (using mature framework helps a lot) you can achieve referencing dynamic variables using structure notation: variables["content_" & id] for your case

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜