Skip to main content
Inspiring
May 28, 2010
Pregunta

custom tags - storing them in their own folder

  • May 28, 2010
  • 3 respuestas
  • 3231 visualizaciones

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

Este tema ha sido cerrado para respuestas.

3 respuestas

Inspiring
May 28, 2010

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.

Inspiring
May 28, 2010

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

Inspiring
May 28, 2010

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>

May 28, 2010

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.

May 28, 2010

"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.