views:

127

answers:

1

I've been adding this to my pages:

pagewithinclude.cfm

<cfinclude template = "_pagename.cfm">

_pagename.cfm

<cfif Not IsDefined("variables.included_pagename")>
<cfparam name = "variables.included_pagename" default = "1">

rest of page

</cfif>

Is there a better way in CF? Something similar to PHP's include_once?

+4  A: 

Nope, what you've done is probably the best way to do it. Although I'd use a Request variable instead.

CF Jedi Master
why is the request scope better?
davidosomething
I think request scope gets Garbage Collected faster?
Henry
The request scope will be available to all calling templates, even if called by cfmodule, cfc, etc.
Ben Doom
both true and valid points, will use request scope. Thanks!
davidosomething