- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Embeds references to ColdFusion pages in CFML. You can embed cfinclude tags recursively. For another way to encapsulate CFML, see cfmessagebox. (A ColdFusion page was formerly sometimes called a ColdFusion template or a template.)
Category
Syntax
<cfinclude template = "template name" runOnce = "true|false">
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
History
ColdFusion 11: The compileextforinclude attribute of the <cfapplication> tag affects the behavior of the <cfinclude> tag.
- By default only files with the cfm and cfml extensions get compiled when included using the <cfinclude> tag. All other files when included using the cfinclude tag will not get compiled but their content will be statically included. No error will be thrown.
- A server-level setting and an application-level setting has been added to specify a list of file extensions that can contain the CFM code. While processing the <cfinclude> tag, ColdFusion checks for this Application-level/server-level setting to decide whether to compile the content or to statically include it. The setting value is comma separated list of file extensions. If file extensions are specified at application-level, the server-level file extension list will be ignored and the application-level file extension list will be used.
- Specifying a special value wildcard (*) in the file extension list makes the cfinclude tag to compile any file.
- The server-level setting can be modified using the ColdFusion Administrator. The setting can be found at Server Settings > Settings page. A new key/tag attribute compileextforinclude added to the application cfc/cfm to specify this file extension list.
ColdFusion 10: Added the attribute {{runOnce}}
ColdFusion MX: Changed error behavior: if you use this tag to include a CFML page whose length is zero bytes, you do not get an error.
Attributes
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
template |
Required |
|
A logical path to a ColdFusion page. |
runOnce |
Optional |
false |
If set to true, the given template (if already processed) is not processed again for a given request. |
Usage
ColdFusion searches for included files in the following locations:
- In the directory of the current page or a directory relative to the current page
In directories mapped in the ColdFusion Administrator
You cannot specify an absolute URL or file system path for the file to include. You can only use paths relative to the directory of the including page or a directory that is registered in the ColdFusion Administrator Mappings. The following cfinclude statements work, assuming that the myinclude.cfmfile exists in the specified directory:
<cfinclude template="myinclude.cfm"> <cfinclude template="../myinclude.cfm"> <cfinclude template="/CFIDE/debug/myinclude.cfm">
But the following do not work:
<cfinclude template="C:\ColdFusion\wwwroot\doccomments\myinclude.cfm"> <cfinclude template="http://localhost:8500/doccomments/myinclude.cfm">
The included file must be a syntactically correct and complete CFML page. For example, to output data from within the included page, you must have a cfoutput tag, including the end tag, on the included page, not the referring page. Similarly, you cannot span a cfif tag across the referring page and the included page; it must be complete within the included page.
You can specify a variable for the templateattribute, as the following example shows:
<cfset templatetouse="../header/header.cfm"> <cfinclude template="#templatetouse#">
Example
<!--- main.cfm ---> <cfinclude template="header.cfm"> <p> Welcome to my cfinclude demo! </p> <cfinclude template="footer.cfm">
header.cfm
<p> Sample header! </p>
footer.cfm
<p> Sample footer! </p>
Real-world uses of the cfinclude function
Corporate intranet portal
Enterprise organizations need consistent branding and navigation across hundreds of intranet pages used by employees for HR, IT support, finance, and project management. The portal must maintain uniform headers, footers, and navigation menus while allowing different departments to manage their own content sections independently, without duplicating layout code or risking brand inconsistency.
Problem statement
- Copying header and footer HTML across hundreds of pages creates maintenance nightmares
- Branding updates require changing every single page individually causing errors and inconsistency
- Different teams working on pages create divergent styles and navigation structures
- No centralized control over corporate branding elements and navigation menus
- Page load bloat from duplicate code across every department page
Solution
The cfinclude tag creates a modular portal architecture where the header, navigation, and footer are maintained in single shared files that are included across all pages. Changes to branding, navigation, or footer information are made once in the shared component files and automatically propagate to all portal pages instantly.
corporate_portal.cfm
<!--- Page-specific data --->
<cfset pageTitle = "Employee Dashboard">
<cfset currentSection = "dashboard">
<cfset userName = "Sarah Johnson">
<cfset userDepartment = "Marketing">
<cfset userRole = "Senior Manager">
<!--- Include shared header --->
<cfinclude template="header.cfm">
<!--- Include shared navigation --->
<cfinclude template="navigation.cfm">
<!--- Main content area --->
<div class="main-content">
<div class="content-wrapper">
<h1>Welcome back, <cfoutput>#userName#</cfoutput>!</h1>
<div class="dashboard-grid">
<div class="widget">
<div class="widget-icon">📊</div>
<div class="widget-content">
<h3>My Tasks</h3>
<div class="widget-value">12</div>
<p>Pending items</p>
</div>
</div>
<div class="widget">
<div class="widget-icon">📅</div>
<div class="widget-content">
<h3>Meetings Today</h3>
<div class="widget-value">3</div>
<p>Scheduled</p>
</div>
</div>
<div class="widget">
<div class="widget-icon">📧</div>
<div class="widget-content">
<h3>Unread Messages</h3>
<div class="widget-value">8</div>
<p>In your inbox</p>
</div>
</div>
<div class="widget">
<div class="widget-icon">🎯</div>
<div class="widget-content">
<h3>Goals Progress</h3>
<div class="widget-value">75%</div>
<p>Quarterly targets</p>
</div>
</div>
</div>
<div class="recent-activity">
<h2>Recent Activity</h2>
<div class="activity-list">
<div class="activity-item">
<span class="activity-time">2 hours ago</span>
<span class="activity-desc">Completed project proposal review</span>
</div>
<div class="activity-item">
<span class="activity-time">5 hours ago</span>
<span class="activity-desc">Attended team standup meeting</span>
</div>
<div class="activity-item">
<span class="activity-time">Yesterday</span>
<span class="activity-desc">Submitted expense report for approval</span>
</div>
</div>
</div>
<div class="info-box">
<h3>💡 How cfinclude Works Here</h3>
<p>
This page uses <strong>cfinclude</strong> to embed three shared components:
</p>
<ul>
<li><code><cfinclude template="includes/header.cfm"></code> - Corporate header with logo</li>
<li><code><cfinclude template="includes/navigation.cfm"></code> - Main navigation menu</li>
<li><code><cfinclude template="includes/footer.cfm"></code> - Footer with links and copyright</li>
</ul>
<p>
All pages in the portal include these same files, ensuring consistency.
When marketing updates the logo in header.cfm, it automatically appears
on all 200+ portal pages instantly!
</p>
</div>
</div>
</div>
<!--- Include shared footer --->
<cfinclude template="footer.cfm">
navigation.cfm
<style>
.main-nav { background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.nav-content { max-width: 1200px; margin: 0 auto; padding: 0 20px;
display: flex; gap: 30px; }
.nav-item { padding: 15px 0; color: ##333; text-decoration: none;
font-weight: 500; border-bottom: 3px solid transparent;
transition: all 0.3s; cursor: pointer; }
.nav-item:hover { color: ##1e3c72; border-bottom-color: ##1e3c72; }
.nav-item.active { color: ##1e3c72; border-bottom-color: ##1e3c72; }
</style>
<nav class="main-nav">
<div class="nav-content">
<cfoutput>
<a href="##" class="nav-item #currentSection EQ 'dashboard' ? 'active' : ''#">
🏠 Dashboard
</a>
<a href="##" class="nav-item #currentSection EQ 'hr' ? 'active' : ''#">
👥 HR Portal
</a>
<a href="##" class="nav-item #currentSection EQ 'it' ? 'active' : ''#">
💻 IT Support
</a>
<a href="##" class="nav-item #currentSection EQ 'finance' ? 'active' : ''#">
💰 Finance
</a>
<a href="##" class="nav-item #currentSection EQ 'projects' ? 'active' : ''#">
📊 Projects
</a>
</cfoutput>
</div>
</nav>
<style>
.main-content { max-width: 1200px; margin: 30px auto; padding: 0 20px; }
.content-wrapper { background: white; padding: 30px; border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px; margin: 30px 0; }
.widget { background: linear-gradient(135deg, ##667eea 0%, ##764ba2 100%);
color: white; padding: 25px; border-radius: 10px; display: flex;
align-items: center; gap: 20px; }
.widget-icon { font-size: 48px; }
.widget-content h3 { font-size: 14px; opacity: 0.9; margin-bottom: 10px; }
.widget-value { font-size: 36px; font-weight: bold; }
.widget-content p { font-size: 12px; opacity: 0.8; }
.recent-activity { margin-top: 30px; }
.activity-list { margin-top: 15px; }
.activity-item { padding: 15px; background: ##f8f9fa; border-left: 4px solid ##667eea;
margin-bottom: 10px; border-radius: 5px; }
.activity-time { font-weight: bold; color: ##667eea; margin-right: 15px; }
.info-box { background: ##e7f3ff; padding: 20px; border-radius: 10px;
border-left: 4px solid ##1e3c72; margin-top: 30px; }
.info-box h3 { color: ##1e3c72; margin-bottom: 15px; }
.info-box ul { margin-left: 20px; margin-top: 10px; }
.info-box code { background: ##fff; padding: 3px 8px; border-radius: 3px;
color: ##e74c3c; font-family: 'Courier New', monospace; }
</style>
header.cfm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<cfoutput><title>#pageTitle# - Corporate Portal</title></cfoutput>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: ##f5f5f5; }
.site-header { background: linear-gradient(135deg, ##1e3c72 0%, ##2a5298 100%);
color: white; padding: 20px 0; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.header-content { max-width: 1200px; margin: 0 auto; padding: 0 20px;
display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 28px; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.user-info { display: flex; align-items: center; gap: 15px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%;
background: white; color: ##1e3c72; display: flex;
align-items: center; justify-content: center; font-weight: bold; }
.user-details { text-align: right; }
.user-name { font-weight: bold; }
.user-role { font-size: 12px; opacity: 0.9; }
</style>
</head>
<body>
<header class="site-header">
<div class="header-content">
<div class="logo">
🏢 <span>ACME Corporation</span>
</div>
<div class="user-info">
<div class="user-details">
<cfoutput>
<div class="user-name">#userName#</div>
<div class="user-role">#userDepartment# - #userRole#</div>
</cfoutput>
</div>
<div class="user-avatar">
<cfoutput>#left(userName, 1)#</cfoutput>
</div>
</div>
</div>
</header>
footer.cfm
<style>
.site-footer { background: ##2c3e50; color: white; margin-top: 50px; padding: 30px 0; }
.footer-content { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 30px; margin-bottom: 30px; }
.footer-section h4 { margin-bottom: 15px; color: ##3498db; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 10px; }
.footer-links a { color: ##ecf0f1; text-decoration: none; transition: color 0.3s; }
.footer-links a:hover { color: ##3498db; }
.footer-bottom { border-top: 1px solid ##34495e; padding-top: 20px;
text-align: center; font-size: 14px; color: ##95a5a6; }
</style>
<footer class="site-footer">
<div class="footer-content">
<div class="footer-grid">
<div class="footer-section">
<h4>Quick Links</h4>
<ul class="footer-links">
<li><a href="##">Employee Directory</a></li>
<li><a href="##">Company Calendar</a></li>
<li><a href="##">Policies & Procedures</a></li>
<li><a href="##">Benefits Information</a></li>
</ul>
</div>
<div class="footer-section">
<h4>Resources</h4>
<ul class="footer-links">
<li><a href="##">IT Help Desk</a></li>
<li><a href="##">Training Portal</a></li>
<li><a href="##">Travel Booking</a></li>
<li><a href="##">Expense Reports</a></li>
</ul>
</div>
<div class="footer-section">
<h4>Support</h4>
<ul class="footer-links">
<li><a href="##">Submit a Ticket</a></li>
<li><a href="##">FAQ</a></li>
<li><a href="##">Contact HR</a></li>
<li><a href="##">Emergency Contacts</a></li>
</ul>
</div>
<div class="footer-section">
<h4>About</h4>
<ul class="footer-links">
<li><a href="##">Company News</a></li>
<li><a href="##">Leadership Team</a></li>
<li><a href="##">Careers</a></li>
<li><a href="##">Privacy Policy</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<cfoutput>
<p>© #year(now())# ACME Corporation. All rights reserved.</p>
<p style="margin-top: 10px; font-size: 12px;">
Last updated: #dateFormat(now(), "mmmm d, yyyy")# |
Powered by ColdFusion cfinclude
</p>
</cfoutput>
</div>
</div>
</footer>
</body>
</html>
Email template
Marketing teams send out hundreds of email campaigns each month for various purposes, including product launches, promotions, newsletters, and customer engagement. Each email requires consistent branding elements such as logos, headers, footers, social media links, and unsubscribe information. However, the content and call-to-action sections need to be unique for each campaign. It's important to maintain brand compliance while also reducing the time spent developing new email designs.
Problem statement
- Copying email HTML boilerplate for every campaign creates version control chaos
- Brand guideline violations occur when teams modify headers or footers incorrectly
- Legal compliance elements (unsubscribe links, privacy notices) inconsistent across emails
- Email designers waste time recreating standard sections instead of focusing on content
Solution
The cfinclude tag builds email templates from modular components, with the email header featuring a logo, the social media footer containing links, and the legal/unsubscribe footer maintained as shared files included in each campaign's custom content.
email_template.cfm
<cfparam name="url.campaign" default="welcome">
<!--- Campaign-specific content --->
<cfswitch expression="#url.campaign#">
<cfcase value="welcome">
<cfset emailSubject = "Welcome to Our Community!">
<cfset heroHeading = "Welcome Aboard!">
<cfset heroSubheading = "We're thrilled to have you join our community">
<cfset heroImage = "🎉">
<cfset ctaText = "Get Started Now">
<cfset ctaLink = "##onboarding">
<cfset contentText = "Thank you for joining us! We've prepared a special welcome guide to help you get the most out of your experience.">
</cfcase>
<cfcase value="promo">
<cfset emailSubject = "Exclusive 30% Off - Limited Time!">
<cfset heroHeading = "Flash Sale!">
<cfset heroSubheading = "Save 30% on all products this weekend only">
<cfset heroImage = "🔥">
<cfset ctaText = "Shop Now">
<cfset ctaLink = "##shop">
<cfset contentText = "Don't miss out on our biggest sale of the season. Use code SAVE30 at checkout. Offer ends Sunday at midnight!">
</cfcase>
<cfcase value="newsletter">
<cfset emailSubject = "Your Monthly Update">
<cfset heroHeading = "Newsletter">
<cfset heroSubheading = "What's new this month">
<cfset heroImage = "📰">
<cfset ctaText = "Read More">
<cfset ctaLink = "##news">
<cfset contentText = "Catch up on the latest product updates, industry insights, and tips from our expert team.">
</cfcase>
</cfswitch>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<cfoutput><title>#emailSubject#</title></cfoutput>
<style>
body { font-family: Arial, sans-serif; background: ##f4f4f4; margin: 0; padding: 20px; }
.email-preview { max-width: 800px; margin: 0 auto; background: white; }
.preview-toolbar { background: ##2c3e50; color: white; padding: 15px 20px;
border-radius: 5px 5px 0 0; }
.campaign-selector { margin-bottom: 20px; text-align: center; }
.campaign-btn { background: ##3498db; color: white; padding: 10px 20px;
margin: 0 5px; border: none; border-radius: 5px;
text-decoration: none; display: inline-block; }
.campaign-btn:hover { background: ##2980b9; }
.info-panel { background: ##e7f3ff; padding: 20px; margin: 20px 0;
border-left: 4px solid ##3498db; border-radius: 5px; }
.component-label { background: ##f39c12; color: white; padding: 5px 10px;
font-size: 12px; font-weight: bold; margin: 10px 0;
display: inline-block; }
</style>
</head>
<body>
<div class="campaign-selector">
<h2>Email Template Assembly Demo</h2>
<p>Select a campaign type to see modular email assembly:</p>
<a href="?campaign=welcome" class="campaign-btn">Welcome Email</a>
<a href="?campaign=promo" class="campaign-btn">Promotional Email</a>
<a href="?campaign=newsletter" class="campaign-btn">Newsletter</a>
</div>
<div class="email-preview">
<div class="preview-toolbar">
<cfoutput>
<strong>Preview:</strong> #emailSubject# |
<strong>Campaign:</strong> #url.campaign#
</cfoutput>
</div>
<!--- Email content starts here --->
<div style="background: white;">
<div class="component-label">INCLUDED: email-header.cfm</div>
<!--- Include shared email header --->
<cfinclude template="email-header.cfm">
<div class="component-label">CUSTOM CONTENT: Campaign-specific</div>
<!--- Campaign-specific hero section --->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" style="padding: 40px 20px; background: linear-gradient(135deg, ##667eea 0%, ##764ba2 100%);">
<div style="font-size: 72px; margin-bottom: 20px;">
<cfoutput>#heroImage#</cfoutput>
</div>
<h1 style="color: white; margin: 0 0 10px 0; font-size: 42px;">
<cfoutput>#heroHeading#</cfoutput>
</h1>
<p style="color: white; font-size: 18px; margin: 0 0 30px 0; opacity: 0.9;">
<cfoutput>#heroSubheading#</cfoutput>
</p>
<cfoutput>
<a href="#ctaLink#" style="background: white; color: ##667eea;
padding: 15px 40px; text-decoration: none; border-radius: 30px;
font-weight: bold; display: inline-block;">
#ctaText#
</a>
</cfoutput>
</td>
</tr>
</table>
<!--- Campaign content --->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding: 40px 20px;">
<p style="font-size: 16px; line-height: 1.6; color: ##333; margin: 0;">
<cfoutput>#contentText#</cfoutput>
</p>
</td>
</tr>
</table>
<div class="component-label">INCLUDED: email-social-footer.cfm</div>
<!--- Include shared social media footer --->
<cfinclude template="email-social-footer.cfm">
<div class="component-label">INCLUDED: email-legal-footer.cfm</div>
<!--- Include shared legal/unsubscribe footer --->
<cfinclude template="email-legal-footer.cfm">
</div>
</div>
</body>
</html>
email-header.cfm
<!--- Shared Email Header Component --->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" style="padding: 30px 20px; background-color: ##2c3e50;">
<table width="600" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center">
<h1 style="color: ##3498db; margin: 0; font-size: 32px; font-weight: bold;">
🏢 ACME Company
</h1>
<p style="color: ##ecf0f1; margin: 10px 0 0 0; font-size: 14px;">
Your trusted partner for success
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
email-legal-footer.cfm
<!--- Shared Legal/Unsubscribe Footer Component --->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" style="padding: 20px; background-color: ##2c3e50;">
<p style="color: ##95a5a6; font-size: 12px; margin: 0 0 10px 0;">
<cfoutput>
© #year(now())# ACME Company. All rights reserved.<br>
123 Business Street, Suite 100, City, State 12345
</cfoutput>
</p>
<p style="color: ##95a5a6; font-size: 12px; margin: 10px 0;">
<a href="##" style="color: ##3498db; text-decoration: none;">Unsubscribe</a> |
<a href="##" style="color: ##3498db; text-decoration: none;">Privacy Policy</a> |
<a href="##" style="color: ##3498db; text-decoration: none;">Contact Us</a>
</p>
<p style="color: ##7f8c8d; font-size: 11px; margin: 10px 0 0 0;">
You're receiving this email because you subscribed to our mailing list.<br>
To ensure delivery, please add noreply@acme.com to your address book.
</p>
</td>
</tr>
</table>
email-social-footer.cfm
<!--- Shared Social Media Footer Component --->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" style="padding: 30px 20px; background-color: ##34495e;">
<p style="color: white; margin: 0 0 20px 0; font-size: 16px; font-weight: bold;">
Connect With Us
</p>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding: 0 10px;">
<a href="##" style="color: ##3498db; text-decoration: none; font-size: 24px;">📘</a>
</td>
<td style="padding: 0 10px;">
<a href="##" style="color: ##1DA1F2; text-decoration: none; font-size: 24px;">🐦</a>
</td>
<td style="padding: 0 10px;">
<a href="##" style="color: ##E4405F; text-decoration: none; font-size: 24px;">📸</a>
</td>
<td style="padding: 0 10px;">
<a href="##" style="color: ##0077B5; text-decoration: none; font-size: 24px;">💼</a>
</td>
</tr>
</table>
</td>
</tr>
</table>