Skip to main content

How to Create a ColdFusion or Lucee Mapping

Create a mapping to define a custom namespace or alias for your ColdFusion or Lucee application. This allows you to organize your code, simplify complex paths, and manage shared resources more efficiently.

Before you begin

You will need:

  • Developer access to the ColdFusion or Lucee Administrator.

  • Access to the server's file system or the ability to modify the ColdFusion or Lucee configuration files.

Create a ColdFusion or Lucee Mapping

Mappings are typically defined in the Application.cfc file or within a specific .cfm or .cfc file to define how the engine resolves paths and objects.

  1. Open your application's main configuration file (typically Application.cfc).

  2. Locate the mappings structure or define a new one.

  3. Define the mapping key and the corresponding path or object.

  4. Save the file.

Example Configuration:

<cfset mappings.images = "images/content/"/>
<cfset mappings.scripts = "js/scripts/"/>

In this example, the developer can now reference mappings.images instead of the full path.

Confirm the result

To verify the mapping is active:

  • Create a new .cfm page and include the Application.cfc file.

  • Use the dump() function to display the mapping.

  • Example: <cfdump var="#mappings#">

  • Confirm that the output displays the correct path or value assigned to the mapping.

Limitations

  • Scope: Mappings defined in Application.cfc are available globally within the application's scope.

  • Case Sensitivity: Depending on your operating system (e.g., Linux), ensure that the paths defined in your mappings match the actual file system casing.

  • Persistence: Changes to mappings in Application.cfc may require a restart of the ColdFusion or Lucee service to take effect if they are defined at the global level.

Did this answer your question?