Andy Jarrett // Code. Develop. Create.

Framework One for when you don't need a framework pt2

This post follows on from my first part and is all about using a framework for even the most simplest sites.

So our family member, Marvin Acme, has come back with the layout for his ACME gadgets to capture and kill rodents site.
Site layout

Being a family member means we're getting paid most likely with canned beer and with that in mind they are notgetting me working on stylesheets!

  1. Create a new folder called layouts in the root of /acme/ and add a file called default.cfm. Inthere place the following snippet:
    <html><title>#rc.pagetitle#<style>*{font-family:"Comic Sans MS";text-align:center;}

    A.C.M.E - Outlandish and downright dangerous products

    #body#
    There are 3 elements in here that relate to the framework
    1. #rc.pagetitle#: the "rc" refers to the Request Context and contains all theURL and form variables from the browser which are also made available to the view directly. We canalso update this variable from within a view for the default.cfm to read, in this case to updatethe page title
    2. buildURL simply creates the index.cfm?action= strings for us. You reference the folder name within theviews/ folder (in this instance we called it main) and the file name (without the .cfm extention)
    3. #body# is where our view file will be populated in to. There is a lot more to the layouts than I needto go in to here so make sure you check out manualto see what else you can do.
  2. In views/main/ add about-us.cfm. In there put the following code:

    About us text coming soon

  3. In views/main/ add countact-us.cfm. In there put the following code:

    Contact us text coming soon

  4. In views/main/default.cfm replace the currect code with the following:

    New site coming soon

You should now be able to go to localhost/acme and see the following:
The site

You're done - obviously minus the content but your 3 page brouchware is setup. No XML config files, setting up debug mode, and thinking about your event names ahead of time head of time.

What is so great about this then?

  • The speed! Yes we could of used no framework and cfmodule on default.cfm, contact-us.cfm, and about-us.cfmbut thats a lot of edits to do if the location of cfmodule changed or you wanted to add a required attribute. Look at what has beenachieved and we spent no time setting the site up and got all the benefits of having a framework!
  • If Marvin came back and wanted a form or some kind of data displayed we have the benfit of the framework and its abiltiy in handlingand passing data around.
  • And again speed! All you've done is created/edited 4 files! No more than if you would of done this without a framework!

Hopefully you've seen that there is no reason not to use a framework even in the smallest of projects. We've managed to create a site and nothave to think about MVC or OO (or even XML config files) but at the same time whilst still having the power of these methodologies in the background in case we need them. Don't see this as I am against MVC or OO its just for some apps you don't need to think about these principles and convention over configuration has made this possible.

In keeping with the series I have some more posts as Marvin already has some idea posting and retrieving data and I'll look at how to grow the site.

Found out more about Framework One via:


I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee. Your support keeps this site running and the coffee brewing! ☕️