Skip to main content
Known Participant
January 25, 2023
Answered

Cfinclude tag throwing error in cfusion2021

  • January 25, 2023
  • 2 replies
  • 708 views

Using cfinclude tag throwing error and recommended to put this.mappings in application.cfc. but how to use that mapping in cfm file with cfinclude tag. Please guide if anyone face smiler issue.

    This topic has been closed for replies.
    Correct answer BKBK

    1. Yes, the Includes folder exists under the views folder C:\inetpub\wwwroot\fujairahport\PermanentPass\views\? then the file breadCrumb.cfm does exist under the Includes folder.

    2. Only Yousaf is here rest moved from here. 


    You can do it in at least 2 ways. The first way is preferable, as it maps directly to the includes.

     

    1st way:

     

    <!--- In Application.cfc --->
    <cfset this.mappings[ "/includes" ] = "C:/inetpub/wwwroot/fujairahport/PermanentPass/views/includes/" >
    <!---In any CFM page in the application --->
    <cfinclude template="/includes/breadCrumb.cfm" >

     

     

    2nd way:

     

    <!--- In Application.cfc --->
    <cfset this.mappings[ "/views" ] = "C:/inetpub/wwwroot/fujairahport/PermanentPass/views/" >
    
    <!---In any CFM page in the application --->
    <cfinclude template="/views/includes/breadCrumb.cfm" >

     

    2 replies

    Known Participant
    January 26, 2023
    I am using cfinclude Syntex
    template="../includes/breadcrmb.cfm>i n one of the cfm page and getting
    following error. Help me come out from this.

    Note: If you wish to use an absolute template path (for example,
    template="/mypath/index.cfm") with CFINCLUDE, you must create a mapping for
    the path using the ColdFusion Administrator. Or, you can use
    per-application settings to specify mappings specific to this application
    by specifying a mappings struct to THIS.mappings in Application.cfc.
    Using relative paths (for example, template="index.cfm" or
    template="../index.cfm") does not require the creation of any special
    mappings. It is therefore recommended that you use relative paths with
    CFINCLUDE whenever possible.
    coldfusion.runtime.EventHandlerException: Event handler exception.
    Charlie Arehart
    Community Expert
    Community Expert
    January 26, 2023

    It means that Cf is not finding the file breadcrmb.cfm (which I hope is not supposed to be breadcrumb.cfm) in a folder that's a sibling of the current folder (that's what the ".." means).

     

    Do you think there should be that file in that folder that Cf should be finding?

     

    As for mappings, they don't apply at all when you use a relative path like that, as the message is telling you. 

    /Charlie (troubleshooter, carehart. org)
    Inspiring
    January 26, 2023

    Thanks, Charlie for your quick reply.

    Here I am trying to put an absolute path as well but still has the same issue.

    RROR!

    An error occurred!

    Action: securityreq.updateexpiryppno
    Error: Could not find the included template C:\inetpub\wwwroot\fujairahport\PermanentPass\views\includes\breadCrumb.cfm.
    Type: MissingInclude
    Details: Note: If you wish to use an absolute template path (for example, template="/mypath/index.cfm") with CFINCLUDE, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc.
    Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with CFINCLUDE whenever possible.
    coldfusion.runtime.EventHandlerException: Event handler exception.

     

    Charlie Arehart
    Community Expert
    Community Expert
    January 25, 2023

    Do you mean "how do I set a mapping in an application.cfm instead of application.cfc"? If so, sadly that's not supported--though it should be.

     

    While the majority of CF docs and references do only show setting application settings in an application.cfc, nearly all such app settings CAN be done in an application.cfm, as an attribute to the cfapplication tag. But sadly, this mappings one is not one of them. (If you try running a cfapplication tag with an invalid attribute, it does what attributes it DOES support, and MAPPINGS is not one of those.)

     

    Or did you mean something else? If so, can you perhaps rephrase your question?

    /Charlie (troubleshooter, carehart. org)