ColdFusioning: Pronunciation \kold-fy�-zhn-ing\ Noun: The action of one that writes ColdFusion.

Building Site Site-Wide Links With ColdBox

Today, we're going to look at using ColdBox to build site-wide links and a global menu. This post assumes you have ColdBox successfully running and are using the standard folder structure for ColdBox.

The first thing we need to do is register an implicit event so we can build our Exit Event Handlers (xeh) for the site. The xeh variables will let us use the links site-wide and have a single point to update the links, should we need to later.

If you open up your Coldbox.cfc, you will see a requestStartHandler. We're going to set this to "general.onRequestStart". You could use any event handler, but we're going to use "general" for this example. Now every request will now run "onRequestStart" in the "general" event handler, before any other code is run. Think of it as a global pre-event.

Next, let's open up general.cfc and add the following function:


<cffunction name="onRequestStart" returntype="void" output="false">
        <cfargument name="event" required="true">
        <cfscript>
            xeh = {
                         home                 = ""
                        ,services        = {
                                                 index                 = "services"
                                                ,consulting            = "services.businesslaw"
                                                ,webdesign            = "services.webdesign"
                                                ,seo                = "services.seo"
                                                }
                        ,about                = "about"
                        ,faq                = "general.faq"
                        ,contactus            = "contactus"
                        ,videos                = "videos"
            };
            event.setValue("xeh", xeh);
        
</cfscript>
    </cffunction>

What this will do is build a struct, xeh, with our different links. Since we put this into the event object, we'll be able to use this anywhere, including our views.

The next step we're going to do is build our menu. Open up your layout file and let's add the following line where we want the menu to display:


<cfoutput>
#renderview(view="menu")#
</cfoutput>

Then go into your /views/ folder and create menu.cfm. This file is where we will build the actual menu. Let's use this menu to utilize the xeh we build above:


<cfoutput>
<ul class="dropdown">
    <li><a href="#event.buildLink(rc.xeh.home)#">Home Page</a></li>
    <li><a href="#event.buildLink(rc.xeh.services.index)#">Services</a>
        <ul class="subnav">
            <li><a href="#event.buildLink(rc.xeh.services.consulting)#">Consulting</a></li><br />
            <li><a href="#event.buildLink(rc.xeh.services.webdesign)#">Webdesign</a></li><br />
            <li><a href="#event.buildLink(rc.xeh.services.seo)#">SEO</a></li><br />
        </ul>
    </li>
    <li><a href="#event.buildLink(rc.xeh.about)#">About</a></li>
    <li><a href="#event.buildLink(rc.xeh.faq)#">F.A.Q.</a></li>
    <li><a href="#event.buildLink(rc.xeh.contactus)#">Contact Us</a></li>
    <li><a href="#event.buildLink(rc.xeh.videos)#">Videos</a></li>
</ul>
</cfoutput>

What this is doing is using the xeh links to construct the links. Now, as long as we build each function in our event handlers to accept the incoming requests, our links will work. Additionally, in any of our views, we can display links, and they will point to the correct location. For example:

Please view our full list of <a href="#event.buildLink(rc.xeh.services.index)#">services</a>.

Then if you need to change a link destination, you can just open up your "general.onRequestStart", update the struct, and site-wide your links will be updated.





ColdBox and Event Default Actions - Shorter Links and SEO

When using ColdBox, you are not required to call an action inside of an event. What this means is if the framework detects an incoming event, and one doesn't exist, it will look for a method called index. If it exists, it will execute it. You can also change the name of the default action in your configuration file.

For example, lets say we have an event handler called services and we call it like this:


index.cfm/services
or
index.cfm?event=services

ColdBox will now look in the services handler for the index method. If it exists, it will treat the request as services.index. This is how your function should look, inside of services:


<cffunction name="index" returntype="void" access="public">
<cfargument name="event">

</cffunction>
</code>
This feature is wonderful on many levels. It lets you create shorter urls and also do some implicit declarations.



Creative Suite 5 is Released - CS5



Massive ColdFusion Resource List

Get your bookmarks ready!

Time to take a visit to the site of the great ColdFusion "troubleshooter", Charlie Arehart. Charlie has put together an exhaustive list of tools and resources for ColdFusion. Titled CF411, the site features over 1,200 links and is quite comprehensive. The greatest part is it appears Charlie is actively maintaining the list, with the last update being only days before this post.

Jump on over to CF411 and bookmark it today: http://www.carehart.org/cf411/





Adobe Labs Ideas - Give Feedback On Your Favorite Products

Adobe now has a way you can give ideas and feedback on a select number of their products. Currently you can "Post Ideas" or "View Ideas" from the following products:

Adobe AIR
Adobe Flash Builder
Adobe Flash Catalyst
Adobe Flash Professional
Adobe Flex SDK
Adobe WorkflowLab

Personally, I think this is a great idea to get a pulse on feedback from the actual users of the product. Sometimes software companies feel they know best on what the users want, and websites like this would help confirm same. However, and more likely, it would give insight into ideas that the company may have never thought of themselves. The only criticism I have is that they only feature six products, out of more than 100 of their current products. The more noticeably missing is Photoshop and ColdFusion. Hopefully, this is just the beginning and they are gearing up to add their flagship products.

Check out the site today and leave a great idea: http://ideas.adobe.com/



CS5 Launch Announced! - Register Now

Adobe has just announced the launch date of the new Creative Suite 5 (CS5). The event will take place on April 12th, 2010, at 9am PDT or 11am EDT. You can reserve your spot today for the event by visiting the URL below. The site below will also have sneak peek videos and social media updates, so check back often.

The site is located at: http://cs5launch.adobe.com

I am pleased to have been on the team, along with Wrecking Ball Media, to design and build the site. We had the pleasure of using Adobe technologies, including ColdFusion, Photoshop and the rest of the Creative Suite products.

Check the site out today!



ColdFusion Builder and FlashBuilder 4 Released

Just released! ColdFusion Builder! Price: $299 and it comes with FlashBuilder 4!

Check out more details: http://www.adobe.com/go/coldfusionbuilder



New Site Launch: CS Buzz

I'm pleased to announce, while working with the great Wrecking Ball Media Team and other numerous fantastic people at Adobe, today we launched the Adobe Creative Suite Buzz Hub:

http://csbuzz.adobe.com/



The site will be a focal point for updates and videos related to Creative Suite. Check it out and let me know what you think.



jQuery: $("#elementID") != document.getElementById("elementId")

Just a quick reminder that in jQuery:

$("#elementID") != document.getElementById("elementId")

They are not the same thing.

If you use $("#elementID") you will return an array. If you want the real DOM element you need to use: $("#elementID").get(0)



AdobeTV Article on Adobe Edge

The wonderful Kush Amerasinghe wrote an article that was just posted on Adobe Edge regarding building AdobeTV. The article is more technical and provides insight into the Adobe technology behind the site. Definitely worth the read:

http://bit.ly/AdobeTVEdge





More Entries