user3733648
user3733648

Reputation: 1333

calling onMissingTemplate function if cfinclude template is missing

the Application.cfc's onMissingTemplate function is a great place to catch error if the user accesses a template in url which does not exists.

But as I have templates which dynamically include the other templates using cfinclude tag. But but if this dynamically generated path does not exist coldfusion does not calls the onMissingTemplate function.

Is there another way to do this?

Upvotes: 0

Views: 303

Answers (1)

Xavier L.
Xavier L.

Reputation: 367

you could catch the error with a cfcatch:

<cftry>
    <cfset x = 'templateName'>

    <cfinclude template="#x#.cfm">

    <cfcatch type="MissingInclude">
       //Do something
    </cfcatch>
</cftry>

Upvotes: 1

Related Questions