ColdFusion Tips and Tutorials

ColdFusion Tips and Tutorials. Tips on ColdFusion, AJAX, CSS, JavaScript, HTML, Design, and more.

CFUnited Developer Conference 2010
Use this code TIPSCUST to get $100 off your registration @ CFUnited! We'll see you There!


ColdFusion Tips
Page 1 2 3
148 ColdFusion, Ajax, FuseBox, Tips, and Tut
147 Included Point of View
146 Javascript - OnFocus
145 Nathan's Rules of Professional Web Desig
144 Universal Server-Side Check | Bandwidth
143 Meeting Schedule | Identification Sessio
142 Breaking Frames Without Javascript
141 Unreal Forms
140 Screen Resolution
139 Human Help
138 Better Server-Side Validation
137 Automatic Server-Side Validation
136 Regular Expression Laboratory,ColdFusion
135 Rank-Ordered Site Search
134 Building Cryptograms
133 Well-Formed Includes
132 Grouping Families for Visits
131 Display Families on a Map Grid
130 Slide Shows
129 Determine Your Database Engine
128 ColdFusion in Context: Maxlength Lies
127 Something Extra
126 Parsing Database Structure from Data Def
125 Valid Values Maintenance
124 Print 1
123 Hide Session Id
122 Downsizing Data to Access
121 Time to Load a Page, FuseBox 4
120 Order and Rank by Subset
119 Warn through E-mail & Update on Paste Sp
118 Paste Spreadsheets, ColdFusion Component
117 Review Files Having Fixed-Length Fields
116 Organized Help
115 Sequence Slider
114 Bad Bits
113 Logical Deduction
112 Whiteout
111 Forced Navigation
110 Managing Permissions
109 Time Travel
108 Test First
107 Get Distance Between Map Coordinates
106 Validating Checkboxes
105 Matrix Manipulation
104 Field Help
103 Fake Object Not Found
102 Rank Order Correlation Coefficient
101 From Calling Pairs to Calling Tree
100 Posting Notice
99 Logout Persuasion
98 Release Session Memory
97 Use Identically Named Fields
96 Web Bug
95 Password Generation
94 Core Queries
93 Use CFFTP
92 Insert, Update, and Delete
91 Stack
90 T-Value
89 Bulk Data Entry and E-mail Validation
88 Quick Reset
87 Design 1
86 Use CFFTP
85 Support Login with AutoPost
84 Login and Site Protection
83 XY Graphs in a Graphing Calculator
82 Read Encrypted Files
81 Showing Progress
80 Frugal Cross-Browser Javascript
79 Tabbed Folders
Page 1 2 3



Custom Search
ColdFusion TIPS PLUS


Issue 00133 http://www.cftipsplus.com

I. My Comments

II. ColdFusion In Context: Well-Formed Includes
By R. Martin Ladner
martin.ladner@charter.net



Advanced, Intensive ColdFusion Training!
Visit this site. If you have plans to get training here is a company
that provides Advanced, Intensive ColdFusion Training. Check them out.
http://www.coldfusiontraining.com/index.cfm?ref=cftipsplus

I. Comments:

Check out the my Photo Gallery of my family and a few other pictures.
http://www.cftipsplus.com/gallery/
I just threw it together since someone asked to see my family.

In case you don't know I sometimes post the ezine here before I release it to the ezine list. So you might want to check here every now and again.


Keep Coding,
Nathan Stanford
http://www.cftipsplus.com

If you have suggestions for articles send them to us.
If you would like to write for cftipsplus.com
send us an email to:

NathanS<at>nsnd.com

IF YOU WANT TO BE AN AUTHOR SEND IN YOUR COLDFUSION TIPS.

Remember this is a great way to get your name known in the
ColdFusion Community.




II. ColdFusion in Context: Well-Formed Includes
By R. Martin Ladner
martin.ladner@charter.net



You may have noticed by now that ColdFusion templates have to be well-formed. You can't just cut up a page into arbitrary templates and have it continue to work. What does that mean to you as a developer?

Data
To explore this concept, you'll need some data. Create the table Item with these column names and some dummy data. (Any data will do.)

ITEM
ItemName,ItemNo
apple,a09
pear,p08
pineapple,p10
quince,q10
egg,e06
jam,j11
jello,j19
lime,l01
omelette,o09
pancake,p45
ham,h3
banana,ba2
basil,b88
water,w18
Main
Put this code in main.cfm...

EXPERIMENT
<p>
<cfquery name="getItems" datasource="context">
select ItemName, ItemNo
from Item
order by ItemName
</cfquery>

1) cfoutput query in parent; plain pounded variable in child.<br>
<cfoutput query="getItems">
#ItemName#
<cfinclude template="more.cfm">
</cfoutput>
<p>

2) cfoutput query in parent; plain output of query variable in child.<br>
<cfoutput query="getItems">
#ItemName#
<cfinclude template="more2.cfm">
</cfoutput>
<p>

3) cfloop query in parent; plain output of query variables in child.<br>
<cfloop query="getItems">
<cfinclude template="more3.cfm">
</cfloop>
<p>

4) query in parent; cfoutput query in child.<br>
<cfinclude template="more4.cfm">
<p>

5) bold in one child; end bold in another
<cfinclude template="more5a.cfm">
ABCDEFG
<cfinclude template="more5b.cfm">
<p>

6) begin cfoutput and pound
variable in one child; end cfoutput in another; watch it die
<cfinclude template="more6a.cfm">
<cfinclude template="more6b.cfm">

Templates
Create the following tiny child templates:
more.cfm...


#ItemNo#
more2.cfm...


<cfoutput>#ItemNo#</cfoutput>
more3.cfm...


<cfoutput>#ItemName# #ItemNo#</cfoutput>
more4.cfm...


<cfoutput query="getItems">#ItemName# #ItemNo#</cfoutput>
more5a.cfm...

<b>
more5b.cfm...


</b>
more6a.cfm...

<cfoutput>#Item#
<!--- this will fail --->
more6b.cfm...


</cfoutput>
Implications for Development
Browse main.cfm and learn from the output...

1) You can't simply include extra output variables by selecting a template of pound-delimited variables; you have to provide something to interpret those variables for output. cfoutput of a query in the parent will not by itself interpret a pounded variable in the child; the raw variable name shows up with pound signs around it.

2) You can't physically nest cfoutput tags on a single page, but you can logically nest them by calling a template that uses them within a pair of cfoutput tags. cfoutput of a query in the parent can control a plain cfoutput tag pair in the child; the interpreted variable name shows up corresponding to the correct row of the query.

3) A loop on a parent page does control execution of a child template. cfloop of a query in the parent can control a plain cfoutput tag pair in the child; the interpreted variable name shows up corresponding to the correct row of the query.

4) You can include an entire output loop in the child based on a query in the parent. cfoutput of a query in the child works just fine based on a query in the parent. (This one looks a bit funny; because, the extra white space introduced by the include in the previous examples is missing.)

5) ColdFusion doesn't care whether HTML tags are paired up; they're interpreted by the client, not by ColdFusion.

6) ColdFusion does want ColdFusion tags to be paired up and will throw an error if they're not.

A ColdFusion tempate has to be well-formed. Pair up your ColdFusion tags on any one page. A cfoutput tag pair in a parent page does control execution of child templates and makes variables available to them. However, it does not interpret (expand) pounded variables in the children; the child must have its own.
=Marty=



SPONSOR ADS:
This e-mail is sponsored by the following ads.


Advanced, Intensive ColdFusion Training!
Visit this site. If you have plans to get training here is a company
that provides Advanced, Intensive ColdFusion Training. Check them out.
http://www.coldfusiontraining.com/index.cfm?ref=cftipsplus


Publisher and Creator:
Nathan Stanford,
NathanS<at>nsnd.com
http://www.cftipsplus.com

Macromedia and ColdFusion are U.S. registered trademarks.


Copyright (c) 2000 - 2003
CFTIPSPLUS.COM and NSND.COM

Permission is granted to circulate this publication via
MANUAL forwarding by email to friends provided that the text is
forwarded in its entirety and no fee is charged.

Photo of Nathan Stanford
Nathan Stanford
LinkedIn

R. Marty Ladner's
Site