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

ColdFusion Now Supports Multiple Data Sources for ORM

With the ColdFusion 9.0.1 update, you can now use multiple data sources with ORM. When you create your objects, use the "datasource" attribute to specify which each should use. Below is an example of it in use:


component        persistent        = true
            accessors        = true
            entityname        = 'Contact'
            hint            = 'This object holds contacts and their associated properties'
            datasource        = 'mydatasource' {

property name='ContactID' type='numeric' persistent=true ormtype='integer' fieldtype='id' generator='increment';
}

If you don't specify a data source, the default data source is used.



Load jQuery From Google Without Risk of Breaking Your Site

We've all heard the best practices recommendation to load jQuery (or other JavaScript libraries) from a CDN, such as Google's for performance reasons. But what happens if, in the rare chance, Google's network is down or inaccessible? At a minimum, your site would start throwing errors & wouldn't function properly.

Fear not, all is not lost. Using the code below, we can try to load the file from the Google CDN and then quickly test if it successfully loaded. If it did load properly, we don't do anything different. But if it didn't, we can load the file from another location, assumingly our web server. Then our site will function properly and once Google's CDN is re-accessible, visitors will continue to benefit from the use of the CDN.


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">
if (typeof jQuery === 'undefined') document.write("<scr"+"ipt src='/js/jquery-1.4.2.min.js'></scr"+"ipt>");
</script>




ColdFusion Developer Population Survey

Please take a minute (very quick) to fill out the survey from Adobe regarding the ColdFusion developer population.

From Adobe:
"There has been a bit of speculation on just how many ColdFusion developers there are in the world today. If you wouldn't mind, please take 1-2 minutes to complete the following survey. If you do, you will have a 1 in 100 chance of winning a copy of ColdFusion Builder."

http://bit.ly/CFDevPop

Thanks!



Tour de ColdFusion Beta Released

We are proud to announce the Tour de ColdFusion Beta is available for download! Check it out today!

http://bit.ly/tourdecoldfusion

If you would like to submit samples, please send them to: submit@tourdecoldfusion.com.



Quick Media and Video Player in ColdFusion 9

If you are using the new ColdFusion 9 and need a quick video player, check out the new cfmediaplayer tag:


<cfmediaplayer
name="Myvideo"
source="./billboard.flv"
width=500
height=400
align="middle"
quality="high"
fullscreencontrol="true"/>


That's how simple it is to implement. Just put the FLV file on your server and change the source attribute above. That all being said, the tag is also very powerful and highly customizable. For a full list of attributes, check out Adobe Help.



ColdFusion 9 Server Lockdown Guide

The Adobe ColdFusion team has published a ColdFusion 9 server lockdown guide. Even if you aren't running your own ColdFusion server, this is a good read and a MUST if you are managing your own servers:


Grab your copy today!!



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>
This feature is wonderful on many levels. It lets you create shorter urls and also do some implicit declarations.



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



More Entries