ColdFusion includes

I am currently studying ColdFusion. I have experience in PHP and am a little confused about this.

I have a selection menu, and I want the settings to be saved in another file. (For example, options.cfm) When I call the file, I want to include options in the selection menu. Now I understand that I could do it something like this:

<select> <cfinclude template="options.cfm"> </select> 

Although what I really want to do is a bit more complicated. I want to save cfinclude inside a variable. I understand that this will not work, but basically I want to execute:

 <cfset options=<cfinclude template="options.cfm">> 

Is there any way to do this? Or at least the best way to accomplish what I do.

+4
source share
2 answers

Take a look at the cfsavecontent tag, which allows you to record what would otherwise be output in response:

 <cfsavecontent variable="options"> <cfinclude template="options.cfm"> </cfsavecontent> 

UPDATE: instead of using cfsavecontent every time you need these parameters stored in a variable, you can do this once inside the options.cfm file. Then, when you include the file, it will create a variable.

 <!--- Inside options.cfm ---> <cfsavecontent variable="options"> <option value="val1">Value 1</option> <option value="val2">Value 2</option> <option value="val3">Value 3</option> </cfsavecontent> 

Then, when you needed this variable, you just would need to include this file.

 <cfinclude template="options.cfm"> 
+9
source

I know this is a little late, but one problem that I see is if it is a site or a client.

if the site is large everywhere, but if it is different from each client, this can cause some problems.

My solution, since I do not use cookies or sessions, is to create a temporary table and write the variables to it. each page that loads and needs these data requests and / or writes to a table. The client identifier variable is created when the client visits the site, and the table is called it.

just a thought.

0
source

Source: https://habr.com/ru/post/1436174/


All Articles