Copy link to clipboard
Copied
I've never used custom tags before, and I'd like to keep my code well organised by putting my custom tags in their own folder.
Looking through the documentation, it says I can either keep them in my applications folder along with my other code (messy) , or I can store them neatly in cfusion/CustomTags
I'm trying to do the latter, so in my application folder, I've created the folder cfusion and in that I've created CustomTags - is this correct ?
I'm getting an error saying my test page can't find the tag ?
If I put the custom tag in the same folder as my test.cfm , it finds the custom tag OK
Copy link to clipboard
Copied
"cfusion/" means the folder in that you installed the coldfusion server. E.g a standalone installation on windows could be in C:\Coldfusion\. And there you find a standard custom tag folder called "CustomTags". Using this folder for your custom tags is only necessary if you want to use your custom tags in more than one application.
If you use per-application settings you can put a custom tag folder definition in the head of your application.cfc:
<cfscript>
customtagpaths = "D:\path\to\your\customtags";
this.customtagpaths = customtagpaths;
</cfscript>
"D:\path\to\your\customtags" should be a folder in your applications root.
or you can set the it in the coldfusion administrator under "Extensions -> Custom Tag Paths".
I think you should create a folder in your application root and set that folder in the coldfusion administrator under "Extensions -> Custom Tag Paths". It's the cleanest solution.
Copy link to clipboard
Copied
RichinternetFrank has answered your question, but I'd just like to comment on your assertion that splitting your files between your application dir & CF's custom tag dir is somehow less messy than keeping them together with the rest of your application's files. My comment is that I disagree with that assertion 😉
But it might stem from your initial idea of where the cfusion/customtags dir resides, I guess.
Personally, I reckon it's better to keep an application's files all in the one place, if poss.
--
Adam
Copy link to clipboard
Copied
Thanks both of you.
Adam
On the contrary, I'm happy to listen to the voice of experience and place the tags where most appropriate
Do you tend to have your application folder look like this ?
index.cfm
<code>
<images>
at present, my application root looks like this
index.cfm
header.cfm
addCart.cfm
showCart.cfm
removeCart.cfm
showMerch.cfm <!---- custom tags mixed with regular web pages --->
<images>
Copy link to clipboard
Copied
I tend to have your application folder look like this:
application.cfc
index.cfm
<customtags> 'set this folder either in the coldfusion administrator or in your application.cfc for using as custom tag path'
<images>
<css>
<views> 'here you can put your other cfm files that are linked from the index.cfm'
Put the file "showMerch.cfm" in the custom tags folder and the other cfm files in the views folder and link to them from your index.cfm. That's it.
Copy link to clipboard
Copied
At the very least I would be separating out which files are web browseable (only files that actually get browsed to should be in your docroot, the rest of the app - which'll probably be most of it - should not be in your webroot), and which files are not. And separate business logic from data-fetching and view/layout files.
I'd usually aim for something like this:
[ColdFusionRoot]
/com/
/companyName/
/applicationName/
/components/
/package1/
SomePackage1.cfc
AnotherPackage1.cfc
/package2/
...
/packageN/
/lib/
/views/
/taglibs/
/taglib1/
someTag.cfm
someOtherTag.cfm
/taglib2/
...
/taglibN/
/www/ <--- webroot
index.cfm
login.cfm
/lib/
/images/
/css/
/scripts/
Where the stuff in www is the only tstuff that's accessible to the outside world. And the taglibs dir would be where I'd put my tag libraries.
--
Adam
Copy link to clipboard
Copied
I'll be running on a hosted server so won't have access to cfusion/customtags
I'll need to specifiy it in the application.cfc or simply mix my custom tags with the rest of my pages
Can I specify a relative path in the application.cfc ? eg. instead of an absolute path like D:\coldfusion\etc... can I specify a path relative to the application.cfc ?
Copy link to clipboard
Copied
Why would you be wanting to access Application.cfc via its file system path?
But if for some reason you needed to, you could resolve the full path via expandPath().
--
Adam
Copy link to clipboard
Copied
I beleive his question was how to set the path of a custom tag mapping IN the application.cfc, not the path to the cfc itself.
But your sugestion expandPath() as well as getCurrentTemplatePaht() functions would be very usefull for that purpose.
Copy link to clipboard
Copied
Aha, indeed.
--
Adam
Copy link to clipboard
Copied
It might not be necessary to set up any paths at all. For the scenario at hand, I would envision a "site root" folder that contained the Application.cfc and any custom tags. The other cfm files would be in subdirectories.
This should allow any of the normal cfm files to find the custom tags.
Mind you, I work for a place where we host ourselves and don't have to deal with this particular situation.
Copy link to clipboard
Copied
The best place to store your custom tags depends in part on where your production files will live. If you are hosting your sites, there are advantages to setting up a special place as per the documentation. One of these advantages is that you can use the tags in more than one application.
If you are going to be on someone else's server, you will likely have no choice but to put your custom tags in the same folder as your Application.cfc file.