I'm a little new to ColdFusion, and I'm trying to figure out how best to use cfinclude'd files. What I consider limited is that the files are included in the string, as if they were part of the inclusion template. This is nice and simple, but it means that any relative paths inside the included file are allowed relative to the included rather than the included file. This becomes a problem in the following file layout:
a.cfm <--- cfincludes b.cfm
b.cfm <--- cfincludes c.cfm
c.cfm
somedir/d.cfm <--- cfincludes ../b.cfm
When a.cfm includes b.cfm, everything works well. When d.cfm includes .. /b.cfm, the inclusion of b.cfm c.cfm will not be executed because it is allowed with respect to d.cfm. So, two questions for my instruction:
Is there any best practice for CF on the lines “the files you expect to include from other files should not include relative links”?
I am trying to understand a constructive solution. I understand that the cfinclude effect looks as if the included file was part of the inclusion - there was elegant simplicity. But are there non-pathological cases where you prefer relative relationships resolved in this way? I can think of cases where I want them to be resolved "traditionally", that is, with respect to the file in which they are located. Maybe I missed something.
source
share