?
Solved

How to ensure initial code is complete before calling other functions in Coldfusion

Posted on 2013-05-30
6
Medium Priority
?
203 Views
Last Modified: 2013-09-06
I have Coldfusion code that is called via cfinclude template. I would like to ensure that the first templates have finished executing before I call the last one.  How do I do this?  

For example:
If my code looks something like:

<cfinclude template="template1.cfm">
<cfinclude template="template2.cfm">
<cfinclude template="template3.cfm">
<cfinclude template="template4.cfm">

I do not want to include the template template4.cfm until the other code is finished.
0
Comment
Question by:WestCoast_BC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:ravi_bachwala
ID: 39208260
Try this one:

Include the Template files prior to template file.

eg:-
Template1.cfm : <cfinclude template = "template2.cfm">
Template2.cfm : <cfinclude template ="template3.cfm">
Template3.cfm: <cfinclude template="template4.cfm">

This way when template one is loaded only template2.cfm would be loaded as template2 loads it would include template3 and so far.. include above lines on the templates at the end of the template files
0
 

Author Comment

by:WestCoast_BC
ID: 39208289
I could do that but the problem is that template2.cfm is used in other areas of the code where I don't want template3.cfm and template4.cfm called.
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 39208719
all cfincludes operate as if they were loaded on the page that contains them. (ie: copy and paste everything from each file onto your master page.)

Ie; server assembles all the includes and then does any calculations...so functioanlly, they all "finish" at the same time.

You need to account for all setting & creation of variables in the code.

You can do things like

<cfif condition1 = x>
<cfinclude...>
<cfelse>
<Cfinclude...>
</cfif>

So shorter answer is you can't control the order in which they load as they are all loaded at once
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 

Author Comment

by:WestCoast_BC
ID: 39217585
Could I do something like the following:

At the beginning of template1.cfm it set a variable to something like:
<cfset condition1 = true>

At the end of template1.cfm it set the variable to something like:
<cfset condition1 = false>

And then I could have something like the following:
<cfloop condition="condition1 eq true">
     Do nothing
</cfloop>
<cfinclude template="template2.cfm">

Would this work?

Thank you for any help you can provide.
0
 

Author Comment

by:WestCoast_BC
ID: 39237826
Can someone please comment on my suggestion above and let me know whether or not it will work

Thank you
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 2000 total points
ID: 39256812
Something like that should work - will depend on exactly what you are doing. give it a shot and let us know if you are having issues.
0

Featured Post

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question