By: Craig
Untitled Document

Fusebox 4.1 For Beginners Part 1

What is Fusebox? Circuit.xml.cfm and Fusebox.xml

Fusebox is a powerful and easy way to create dynamic sites and large programs for the web. It allows multiple users to work on the same project at once without worrying about each others code (as long as the basics are known such as db name and where images are stored, etc). It is also a great way for single coders to create powerful and compelling web sites and programs with ease. What makes fusebox coding so great is its simplicities of coding. You can create just small little files and maintain them easily and effectively. Also with fusebox if one part of your program or site is broke or not working it doesn't affect the rest of your site or program.

We all know what a fusebox is. If you own a computer you are using a fuse box right now. It's usually located in a basement or closet and it allows you to cut the power to any given room or rooms you would like. If you accidentally drop your hairdryer into the tub a fusebox will have a fuse blow protecting you from sudden death (hopefully). It is the same idea behind fusebox 4.1.

To follow this tutorial please go to http://www.fusebox.org and download your copy of fusebox 4.1 and unzip it to your wwwroot folder. Once you have that done we can begin.

Open up your favorite code editor (I am using dreamweaver but any will do.) and create a file called circuit.xml.cfm. Save it to the same folder as your index.cfm file is in.

Now this file is sort of like the brain of the fusebox. It will house the information that each circuit will do. But before we get into that lets put some code in here. Place the following code into the circuit.xml.cfm page.

<circuit access="public">
</circuit>

Circuit.xml.cfm

<circuit access="public">
</circuit>

If you're rubbing your temples and scratching your head at this don't worry you are not going crazy. This is XML in a CFML document without the use of cfsavecontent tag. If you are wondering what cfsavecontent is don't worry about it now you won't need it for this tutorial series.

Ok now that we have the basic for circuit.xml.cfm laid out lets open the fusebox.xml document you have unzipped. Now take a minute to study this document. It is an XML document. The first tag opens the fusebox. The next tag you see is the <circuits> tag. Notice that it also has a closing tag and that there is nothing in between. Now go down the page a little bit and you will see some more tags that are called "parameter" You will see 14 of them. Now if you are reading through them your head is probably starting to hurt. I know mine did at first.

Don't worry what they all mean just yet. Let's just focus on the one with the name of "defaultFuseaction". Notice that the value is "main.welcome". Ok now if you have a testing server running cfmx 6 or above open up index.cfm that was included in the fusebox 4.1 download and open it in your browser. You should see a error message that says something along the lines of, " You specified a Circuit of main which is not defined." So what happened? The index page is the main controller of everything in your fusebox. It is the box that makes up your fusebox. Every single item has to pass through the index.cfm page. So why isn't it working? It is not working because we have no circuit called main. Let me take a moment to explain something here before we fix our broken circuit.

Your circuits can be named anything you would like them to be as long as it is not something reserved by coldfusion. In this case our circuit is named main. It was defined in the fusebox.xml document set in the parameter named "defualtFuseaction". It looked like this main.welcome. So what happened to the welcome? The welcome is the fuse action. It is what the circuit main does. So it would read something like this to a server. The user would like to view the circuit main and the action this circuit is to perform for the user is welcome.

Ok now that we have explained this lets fix the broken circuit. First step we must take is to create the circuit main. Go back to your fusebox.xml document and go back up to the circuits tag. Now type in between the opening and closing circuit tags the following:

<circuit alias="Main" path="" parent="" />

Fusebox.xml

<fusebox>
<circuits>
    <circuit alias="Main" path="" parent="" />
</circuits>

 

What we just did was created a circuit called main. NOTE: Remember that everything in XML must have a closing tag.

Once you have done that open circuit.xml.cfm and place this following code in it making sure you place it in between the circuit tags:

<fuseaction name="Welcome"></fuseaction>

Circuit.xml.cfm
<circuit access="public">
    <fuseaction name="Welcome"> </fuseaction>
</circuit>

Now you have created the circuit and the action it is to do!

Once this is completed move on to the second part of the tutorial.

About This Tutorial
Author: Craig
Skill Level: Beginner 
 
 
 
Platforms Tested: CFMX,CFMX7
Total Views: 215,839
Submission Date: July 04, 2005
Last Update Date: June 05, 2009
All Tutorials By This Autor: 10
Discuss This Tutorial
  • I am not sure how to answer this being you should get nothing with this first step in the tutorial. Just a blank page when viewed through the browser. What you show as code above is the index page as it should look when viewing it as code in an editor. If you could provide me with something more as to what you have done thus far it would help me help you.

  • HI! I tried the first excersice but this is what i got: --- Thanks.

  • Jay I searched before writting this tutorial series and found nothing either than the documentation at fusebox.org. I plan on writing more on fusebox within the next few months. (with any luck.) But if you find some let me and everyone else know as well. Meanwhile if you have a question just email me and I will try to answer it for you.

  • Anyone know of any online tutorials beyond this?

  • For everyone who found the explaination of the index.cfm file a little confusing. The index.cfm file is like the center of a spider's web. All the connections and actions start and end there. When your fusebox program/site is first swung into action by a visitor it goes out and connects to your welcome page. Once it is found it returns the results or display that it was told to get. When your user clicks on a link to another page in your site they in turn tell your index.cfm page to go get the page that deals with that "fuseaction". Your index.cfm is thus likened to a cfswitch statement. The differnce between a cfswitch statement and the index.cfm in fusebox is that the cfswitch statement is a flat spiders web or 2D where the index.cfm file is more like a ball of webbing or 3D thus allowing the index.cfm page to move up, down, left, right, back, forward, and every which way you can think of where as in a cfswitch statement you can only go down the statement till you find or don't find something that matches.

  • PLEASE NEED HELP? In the Fusebox4.1 Tutorial, I didn't understand what to put on Index.cfm .... and I'm a bit lost ... please could you help me? My address is marcelo_teteco@hotmail.com Thanks you Marcelo

  • If anyone needs help with this toturial I wrote please don't hesitate to email me dirrectly at kick12380@yahoo.com. I will repond to your questions quicker that way, because I don't always get a chance to be on easycfm but I always have my mail open. :-)

Advertisement

Sponsored By...
Healing Touch Massage - $39.00 - 50 Minute Deep Tissue Massage Dripping Springs, Texas!