Home arrow ColdFusion arrow Page 3 - Introduction to ColdFusion Markup Language, concluded
COLDFUSION

Introduction to ColdFusion Markup Language, concluded


If you want to get a good start on learning ColdFusion, look no further. This article covers a whole bunch of CFML tags and some basic functions. It is the second of two parts, and excerpted from chapter three of the book ColdFusion Web Development with Dreamweaver MX 2004, written by Jen and Peter deHaan et al. (Apress; ISBN: 1590592379).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 41
January 26, 2006
TABLE OF CONTENTS:
  1. · Introduction to ColdFusion Markup Language, concluded
  2. · Query Loop
  3. · Collection Loop
  4. · The cfdirectory tag
  5. · The cffile tag
  6. · The cfform tag

print this article
SEARCH DEVARTICLES

Introduction to ColdFusion Markup Language, concluded - Collection Loop
(Page 3 of 6 )

The final loop type loops over a collection, or structure. Structures (sometimes referred to as "associative arrays" in other programming languages) are containers for data, and that data is accessed by using what is called a key. In the following example demonstrates looping over a structure named#CGI#and accessing its contents by providing the key to the structure. The CGI structure is a special structure containing run-time information created by the ColdFusion Server. In fact, every "scope" (variable prefix) is exposed to your page as a structure. You can loop over "form," "url," "variables," and so on. For each iteration through the loop, we are setting a variable called#item#that is used to hold the current key. We cover structures in more detail in Chapter 4.

Enter the following code block into a new Dreamweaver document (colloop.cfm):

<table>
 
<cfloop collection="#CGI#" item="item">
    <cfoutput>
     
<tr>
       
<td>#item#</td>
       
<td>#CGI[ item ]#</td>
      </tr>
   
</cfoutput>
  </cfloop>
</table>

Test the document in a browser, and you will see all of the CGI variables in the window, as shown in Figure 3-13. (Only a small sample is shown here.)


Figure 3-13.   Using a collection loop to output all the CGI variables

<cfmail>

We briefly touched on<cfmail>in Chapter 1.This tagis responsible for sending e-mails from within ColdFusion applications to a designated e-mail address. Unlikemailto: linksin HTML, the mail is sent via an SMTP mail server and not the users mail client and mail server. Typically,<cfmail>is used to send news-letters and reminders to users, or error messages to administrators.

The basic syntax for the<cfmail>tag is as follows (cfmail.cfm):

<cfmail to="admin@yoursite.com" from=name@visitor.com
        subject="This is the subject">
  The message of the e-mail goes here. </cfmail>

Several other options for the<cfmail>tag allow you to attach files to the e-mail or specify whether you want to send an e-mail with HTML formatting, and so on. However, we go through only the basic options here. Follow these steps to use this tag in Dreamweaver.

  1. Create a new ColdFusion file in Dreamweaver MX, click on the CFML Advanced tab, and click on the CFMAIL icon, which is the little envelope icon ninth from the left on the toolbar, as shown in Figure 3-14. This will cause the Tag Editor - Cfmail dialog box to open.

                                           



    Figure 3-14.
       The Dreamweaver MX 2004 Insert bar with the advanced CFML functions shown and the cfmail button illustrated 
  2. In the dialog box General tab, you can set the values of the To, From, and Subject attributes by using the appropriate text fields, as shown in Figure 3-15. You can also set CC and BCC addresses.

                                              


    Figure 3-15.   The Tag Editor - Cfmail dialog box's General tab
  3. Next, click on the Message Body tab, fill in the body of the e-mail, and from the drop-down menu select whether you are sending a plain text e-mail or an HTML e-mail.
  4. If you haven't defined a mail server within the ColdFusion Administrator, you can click on the Server Settings section and define your mail server, port, and timeout settings. If you try sending e-mails without defining server settings in the Administrator or within the tag, the e-mail will not be sent and will end up in an undeliverable folder.
  5. Click on the OK button, and the code (as shown previously) is automatically inserted into the Document window.


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