I want to:
- on every page,
- check if a file exists
- include that file if TRUE
i.e.:
<cfset variables.includes.header = ExpandPath("_inc_header.cfm")>
<cfif FileExists(variables.includes.header)>
<cfinclude template = "_inc_header.cfm">
</cfif>
Is this a good idea?
edited to use just “_inc_header.cfm” as the template
Alternative practical use would be something akin to this PHP code:
foreach (glob("includes/*.php") as $inc) {
require($inc);
}
Depending on traffic, there could be a bit of a performance hit.
Could you put the include statement within a try/catch or failing that, maybe save the result of the check in a session and then just do the check once per file per session?