Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 152

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
The model of an included page is that it is part of your page; it just resides in a separate file. The
pass parameters to the included page, but the included page has access to all the variables on the page that includes it.
The following image shows this model:
<html>
...
<cfinclude template=
"Template.cfm">
...
</html>
MyPage.cfm
MyPage.cfm
Using the cfinclude tag
When you use the
cfinclude
another page is referred to as the calling page. When ColdFusion encounters a
calling page with the output from processing the included page. The included page can also set variables in the calling page.
The following line shows a sample
<cfinclude template = "header.cfm">
Note: You cannot break CFML code blocks across pages. For example, if you open a
page, close the block on the same page; you cannot include the closing portion of the block in an included page.
ColdFusion searches for included files as follows:
• The
attribute specifies a path relative to the directory of the calling page.
template
• If the template value is prefixed with a forward slash (/), ColdFusion searches for the included file in directories that
you specify on the Mappings page of the ColdFusion Administrator.
Important: A page must not include itself. Doing so causes an infinite processing loop. To resolve the problem, stop the
ColdFusion server.
Include code in a calling page
Create a ColdFusion page named header.cfm that displays your logo. Your page can consist of just the following
1
lines, or it can include many lines to define an entire header:
<img src="mylogo.gif">
<br>
(For this example to work, you must also place your logo as a GIF file in the same directory as the header.cfm file.)
Create a ColdFusion page with the following content:
2
<table>
<tr><td>
Included Text here
</td></tr>
</table>
Template.cfm
<html>
...
<table>
<tr><td>
Included Text here
</td></tr>
</table>
...
</html>
tag to include one ColdFusion page in another ColdFusion page, the page that includes
tag:
cfinclude
Last updated 1/20/2012
cfinclude
tag it replaces the tag on the
cfinclude
block in a ColdFusion
cfoutput
147
tag cannot

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents