ColdFusion: custom tags location

Written on 21 March 2011, 03:17pm

Tagged with:

Just bookmarking this:

1. In the same directory as the calling page – while this is easy for demonstration purposes, it’s not very practical, as it means that the custom tag is only available within that directory.
2. In a directory (or subdirectory of a directory) specified in ColdFusion Administrator under Extensions -> Custom Tag Paths.
3. In the cfusion/CustomTags directory or one of its subdirectories.

– CF tutorial

This post highlights the difference between the ColdFusion Administrator Mappings section and the virtual directories.
The ColdFusion 8 and 9 Admin documentation pretty much explains everything (see highlighted note):

ColdFusion mappings let the cfinclude and cfmodule tags access pages that are outside the Web root. If you specify a path that starts with the mapping’s logical path in these tags, ColdFusion looks for the page using the mapping’s directory path.
ColdFusion also uses mappings to find ColdFusion components (CFCs). The cfinvoke and cfobject tags and CreateObject function look for CFCs in the mapped directories.
Note: These mappings are independent of web server virtual directories. If you would like to create a virtual directory to access a given directory through a URL, please consult your web server documentation.

So, the mappings defined in the CF Admin (CFAdmin > Server Settings > Mappings) are defined so that ColdFusion is able to access pages outside of your web root. That’s because ColdFusion will not ‘see’ the virtual directories defined in your web server configuration.
Either if you use the JRun server, Apache or other flavors, the ColdFusion will not know anything about their configuration.

Let’s take an actual example: (more…)

Try the following example in your browser.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test js length</title>
#foo {width: 420px; height:70px; font-size:12px;}
#sbmt_btn {font-size:12px;}


<cfset str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Pellentesque bibendum tristique dignissim.">

String Length=#len(str)# characters

<form action="##" name="form1" id="form1" method="post" onsubmit="myfunc()">
	<textarea name="foo" id="foo" cols="30" rows="3">#str#</textarea> <br />
	<button type="submit" name="sbmt_btn" id="sbmt_btn">Submit</button>
<script type="text/javascript">
function myfunc()
	var myval = document.getElementById('foo').value;