Skip to content

Instantly share code, notes, and snippets.

@learncfinaweek
learncfinaweek / gist:4121048
Created November 20, 2012 20:58
Basics - Script vs Tag

ColdFusion has been designed to allow the use of ColdFusion tags and ColdFusion script. Functionally, both will be interpreted equally and will achieve the same result. The use of ColdFusion Tags and ColdFusion Script is up to personal or team preference. One or two ColdFusion operations are currently Tag only, as of this tutorial, but these will be made available in ColdFusion script in future releases.

Some developers write all ColdFusion code in Tags. Some developers write all ColdFusion code in Script. Some write the view portions of their ColdFusion code in Tags and the business layer portion in Script. As long as you stay consistent, all approaches are valid. The overarching rule should be legibility and consistency.

Let's look at some statements and compare the differences:

@learncfinaweek
learncfinaweek / gist:4120988
Created November 20, 2012 20:48
Setup - Installing MySQL

ColdFusion has the ability to communicate with a number of different databases, which will be covered later on in this course; for the sample application we will be working on throughout the course, we will be using MySQL. If you already have MySQL 4 or 5 already installed, you can proceed to the 'Install Sample Files' section. If not, follow the steps below:

Windows

  1. Open up a browser and go to: http://dev.mysql.com/downloads/mysql/
@learncfinaweek
learncfinaweek / gist:4121006
Created November 20, 2012 20:50
Basics - What is ColdFusion?

ColdFusion is a rapid development platform for building modern web applications. ColdFusion is designed to be expressive and powerful. The expressive characteristic allows you to perform programming tasks at a higher level than most other languages. The powerful characteristic gives you integration with functionality important to web applications like database access, MS Exchange access, PDF form creation and more.

The ColdFusion platform is built on Java and uses the Apache Tomcat J2EE container. While you have full access to Java and Tomcat, you need not worry about these details. You'll interact with ColdFusion and the user friendly ColdFusion Mark-up Language (CFML) to write your programs. Your ColdFusion files will use the file extension '.cfc' for objects and '.cfm' for pages. CFML requires much less ceremony and infrastructure than typical java while offering a significantly faster development experience than Java.

After taking this CF in a Week series, you'll have the basics n

@learncfinaweek
learncfinaweek / gist:4121092
Created November 20, 2012 21:02
Decision Making and Scopes - Hands On 3
<p>
In this hands on, you are going to add some conditional logic to the site as well as create a form post.
</p>
<p>
<strong>Tags Used</strong>: <a href="http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fe8.html" target="_new">&lt;cfif></a>, <a href="http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7faf.html" target="_new">&lt;cfparam> </a>
</p>
<p>
<ol>
<li>
Open up the <span class="code">/www/contact.cfm</span> file in your code editor.
@learncfinaweek
learncfinaweek / gist:4121012
Created November 20, 2012 20:51
Basics - Datatypes

In our last Section, we talked about variables, data, and how to transport data around in your application. Different data types serve different purposes.

Strings/Numbers

Is Simple: Yes

@learncfinaweek
learncfinaweek / gist:4121015
Created November 20, 2012 20:52
Basics - Commenting

In our previous sections we talked about the importance of adding context into your programs. You’ll find you will spend much more time reading programs for the purposes of debugging and enhancing, than you spend writing the program. So take care to write your programs in such a way the program can be read and understood as easily as possible.

Context is important because our programs express a problem to a computer using a kind of shorthand, in our case ColdFusion programming code. The computer doesn’t much care about the amount of context in the application, as long as the instructions (code) are all properly formed. The program is good enough for the computer if it works well. But this doesn’t necessarily mean the program is good enough for a human. Programs that are good for humans can be efficiently understood, debugged and enhanced by another programer.

One way to add context is to use descriptive variable names.

@learncfinaweek
learncfinaweek / gist:4121052
Created November 20, 2012 20:58
Basics - Hands On 1

In the first part of this hands on we are going to convert some pages to .cfm pages. We will then add some variables and output them to the user. Finally, we will add a comment to our code.

Tags Used: <cfset>, <cfoutput>

  1. Rename the /www/index.html file to index.cfm.
@learncfinaweek
learncfinaweek / gist:4121057
Created November 20, 2012 20:59
Basics - Hands On 2

In this section of the hands on we will switch from tag based code to script based code and create a structure of data. We will then output that on the page.

Tags Used: <cfscript>, <cfoutput>

  1. Open up the /www/about.cfm file in your code editor.
@learncfinaweek
learncfinaweek / gist:4121103
Created November 20, 2012 21:04
Decision Making and Scopes - Hands On 6

In this hands on, we are going to refactor our code and take out any unnecessary logic we might have.

Tags Used: <cfif>, <cfelse>

  1. Open up the /www/contact.cfm file in your code editor and locate the <cfif> statement that checks the form.contactname variable. Remove the eq 0 part of the expression; as any number greater than 0 is treated as true, and the number 0 is treated as false, we do not need this additional part of the <cfif> statement. Because we only want to run the code when there is NO value passed we must negate the value by putting the word NOT before
@learncfinaweek
learncfinaweek / gist:4121113
Created November 20, 2012 21:05
Looping - Hands On 7

In this hands on, we will perform some simple looping using a list and output it to the page.

Tags Used: <cfset>, <cfloop>, <cfoutput>

  1. Open up the /www/resume.cfm file in your code editor.