Home arrow ColdFusion arrow Page 5 - Welcome to Coldfusion MX 6.1, concluded
COLDFUSION

Welcome to Coldfusion MX 6.1, concluded


This article, the second of two parts, explains how to use ColdFusion 6.1 in conjunction with Dreamweaver MX 2004 to build dynamic web sites. It is excerpted from chapter one of the book ColdFusion Web Development with Dreamweaver MX 2004, written by Jen and Peter deHaan et al. (Apress, 2004; ISBN: 1590592379).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
December 29, 2005
TABLE OF CONTENTS:
  1. · Welcome to Coldfusion MX 6.1, concluded
  2. · Data and Services
  3. · Debugging and Logging
  4. · Setting Up a Site in Dreamweaver MX 2004
  5. · Getting Started with CFML

print this article
SEARCH DEVARTICLES

Welcome to Coldfusion MX 6.1, concluded - Getting Started with CFML
(Page 5 of 5 )

One of ColdFusion MX 6.1’s greatest strengths is the simplicity of its tag-based language, CFML. If you have experience with coding HTML, the migration to ColdFusion MX 6.1 should be very easy. Like HTML, CFML is not case-sensitive, so it doesn’t matter if you type a tag in uppercase, lowercase, or mixed case. In this section, we are going to run through a few CFML tags. For developers used to a JavaScript-like syntax, CFML supports CFScript, which allows access to most ColdFusion MX 6.1 functionality through a more traditional coding style. We provide several more in-depth examples in Chapter 3.

Setting a Variable

To set a variable in a page, type

<cfset myVar = "myValue">

To output this variable, type

<cfoutput>#myVar#</cfoutput>

If you save this code in a.cfmfile and view it in a web browser, the text “myValue” will be output to the screen.

When you output variables in ColdFusion MX 6.1, remember that they must be enclosed in pound signs (#). Without pound signs, ColdFusion MX 6.1 assumes that you want to output a string, so typing<cfoutput>myVar</cfoutput>would simply output myVar to the window. Likewise, if we forget the<cfoutput>tags, ColdFusion MX 6.1 won’t parse the variables, and #myVar# will show up as the output! One place where ColdFusion MX 6.1 differs from other programming languages is that it doesn’t require you to declare a data type for a variable before setting a value. ColdFusion MX 6.1 automatically converts variables and determines their data type for you.

Functions

ColdFusion MX 6.1 also has a very extensive list of functions available, including the ability to create your own user-defined functions (UDFs). For example, you could simply add<cfoutput>#Now( )#</cfoutput>to a web page to have it display the current server date and time on the screen.#Now( )#is a built-in ColdFusion MX 6.1 function that takes no arguments and returns the current date and time of the server. Several other date and time functions allow you to extract just the year, month, hour, second, or any component of a date, along with numerous other formatting options to choose for displaying dates.

Looping with <cfloop>

This tag has a few different parameters and performs different tasks depending on which attributes you specify, but one of the easiest ways to call this tag is like this:

<cfloop from="1" to="3" index="i">
  ...
</cfloop>

This example loops from 1 to 3. This is similar to afor...nextloop structure in other languages. Using other attributes of the<cfloop>tag,do...whileand other types of loops can be used. For each time you go through the loop, you set a variable called“i”that holds the current value. If you changed the code to:

<cfloop from="1" to="3" index="i">
  <cfoutput>#i#</cfoutput>
</cfloop>

It would generate the following output:

1 2 3

Sending Mail with <cfmail>

ColdFusion MX 6.1 allows you to send e-mails quickly and easily by using the <cfmail> tag, as shown in the following snippet:

<cfmail from = "admin@yourdomain.com" to = "info@yourdomain.com"
 
subject = "your subject here">
 
this is the body of the e-mail.
</cfmail>

As long as you have entered a valid mail server in the ColdFusion MX 6.1 Administrator, you will be able to send e-mails from ColdFusion MX 6.1. You could easily modify this example to allow you to send e-mails to a variable that a user typed into a web form; this would enable you to build a simple form that allows visitors to e-mail questions and feedback to the webmaster.

Summary

In this chapter, we described many different areas of the ColdFusion MX 6.1 environment, such as the CFML language, ColdFusion MX 6.1 application server, and how these interact with Dreamweaver MX 2004. We covered:

  • The background and history of ColdFusion and how it integrates with the Web today
  • The advantages and disadvantages of ColdFusion MX 6.1
  • How to install and set up the standalone version of ColdFusion MX 6.1 server on the Windows platform
  • How to set up a ColdFusion MX 6.1 web site in Dreamweaver MX 2004
  • How to get started with CFML

The next chapter focuses on using databases and SQL, which is used to select, insert, update, and delete data from databases. We will also take a look at how to create a data source in the ColdFusion MX 6.1 Administrator, which allows ColdFusion MX 6.1 to talk to databases.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials