Join Candyce Mairs for an in-depth discussion in this video ColdFusion templates, part of Learning ColdFusion 10.
At this point in time, I have ColdFusion 10 installed. I have ColdFusion Builder 2 installed. And I also have my file set up within ColdFusion Builder as a new project. Now, within my Project files, there are two folders that I do not need to have within ColdFusion Builder. So, I'm going to go ahead and delete those. And those are these two here that were contained in my Travel ADV course files.
Those are specifically Dreamweaver related files. At one point, I had this website open in Dreamweaver, and that's where those two items came from. So, I'm going to simply select them by holding Ctrl or Cmd down, and hitting the Delete key on my keyboard. I kept them in there because I want to show you how to delete files from within the navigator as well as add files, which we will be doing in a moment.
Also within the course files, I do have a folder, and this folder contains PowerPoints. And one of those is the ColdFusion Page Request PowerPoint. I'll be coming back to that PowerPoint when I explain how ColdFusion pages are put together. So, I just want you to know that that's located in here as well. Now that our website is set up, these are pre-built pages that I've created for you. How do you create a brand new page from scratch? You create a new ColdFusion page the same way we created a new ColdFusion project.
So, I can Right-click the Project folder, go up to New, and choose New ColdFusion Page, and that's exactly what I'm going to do. Now just double check and make sure that, that location is always in the Travel ADV folder. I like to double check that in case it's not. Browse out to that folder within the ColdFusion 10, CFusion, www.root folder.
I'm going to title this, let me say New Page because that's all it is. I'll click Finish. And as soon as I do that, ColdFusion Builder adds it to my course files. And also open it within the interface. Now, up at the top of the ColdFusion Builder interface, you have these four tabs. And those allow you to work in those four types of files.
The other thing you have down at the bottom of the interface, and I'll just go back to the CFML for now. You also have up Firefox. And because I'm on a Windows system, and Internet Explorer was already installed, I also have an Internet Explorer little tab. Now if I click Firefox, I get this message. And this is ColdFusion Builder asking me, before you preview the file if you have not saved this file, do you want me to automatically save the file? And I will say, Yes. That's a handy feature.
And you can see my very exciting page. If I click on Internet Explorer, I get the same page. Here's my Source file. It's completely blank. Now, as you click these different tabs up here, what it does is allow you to have access to the shortcuts for creating tags. So in the HTML tab, I can insert a form tag just by just hitting this button, and you can see a form tag goes in. I'll just delete that.
Now, if I Right-click, there are a lot of options available to me, one of which is Save. So, I'll go ahead and do that. Now that I've saved the page, I do not have an asterisk. Now, ColdFusion pages have a .CFM extension, you can see ColdFusion Builder automatically added that for us. That .CFM extension tells the web server to send this page to the ColdFusion server for processing. And it does that automatically, whether there's ColdFusion code on the page or not, simply because of this file extension.
Now, you will hear ColdFusion pages referred to as a template page. And technically, it's not a template like you think of a template for Word or PowerPoint, or whatever other programs you've worked with templates. The reason the word template is used is because ColdFusion processes the page, and basically puts the page together for us. So, it's technically a template page 'till ColdFusion is done processing the page and goes to send that page back to the web server as pure HTML.
And let me move out to this slide to show you that particular process. So the ColdFusion server, what does it do? It processes the ColdFusion coding, it communicates with the database, and then it assembles the page once it's done with all of that. So basically, when ColdFusion gets the page request from the web server, ColdFusion goes through all of the code on the page. If any code needs to be sent to the database, to receive information, ColdFusion does that communication. You communicate with the database through the language of SQL, standing for Structured Query Language.
So, ColdFusion makes the database request. ColdFusion gets the information back from the database and gathers all of that and assembles the page. So, that's why it's technically called a template. It isn't assembled until all of the code comes back to the ColdFusion server, and ColdFusion puts the page together. Once the page has been put together by ColdFusion, it gets sent back to the web server and then forwarded back to the user's browser. So when I use the word template, that's what I mean. I'm just referencing the page with the .CFM extension. Because sometimes those pages that ColdFusion puts together are actually four or five different pages put together.
And database information has also been added to that page, so that's why we call it a template. It gets assembled by ColdFusion and sent back to the server. So, that is a ColdFusion template page, simply a page with a .CFM extension that ColdFusion has processed and sent back to the web server to go to the user's browser.
- Understanding static vs. dynamic requests
- Using the ColdFusion Administrator
- Creating, displaying, and scoping variables
- Working with include files
- Pulling data from a database
- Displaying and modifying database data
- Passing data between pages
- Working with form data
- Populating form fields with query data