cfinclude
permet d'inclure une page ColdFusion dans une autre.
À l'exécution, quand ColdFusion retrouve l'instruction pour inclure une page ColdFusion,
il exécute cette page comme s'elle faisait partie du code de la page courante.
Ce qui veut dire que le code de la page inclut partage le même scope VARIABLES
de la page courante (ce qui n'est pas le cas avec le tag cfmodule
).xxxxxxxxxx
<cfinclude template = "../anotherpagetoinclude.cfm">
Attribut | Requis | Description |
---|---|---|
template | Chemin logique d'une page ColdFusion. |
xxxxxxxxxx
<cfscript>
include "anotherpagetoinclude.cfm";
</cfscript>
xxxxxxxxxx
<cfinclude template = "C:\anotherpagetoinclude.cfm">
xxxxxxxxxx
<cfinclude template = "http://www.mtitek.com/anotherpagetoinclude.cfm">
xxxxxxxxxx
Error Occurred While Processing Request
Could not find the included template http://www.mtitek.com/anotherpagetoinclude.cfm.
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.