fusiongrokker

Entries for month: February 2009

Everything you need to know about Mango pods - Part 1: Simple Template Pods

In Mango, adding pods can be super simple -- mostly html with a touch of CFML; or you can go nuts and write a plugin that adds a pod that does something crazy. In this series of posts I'll try to cover everything you could possibly want to know about pods.

Before we get started, the first thing you need is a pod-enabled theme. They aren't all pod enabled, unfortunately. If you're not sure if your theme is pod-enabled, the quick way to tell is to click the "Pod Manager" link on the left side of your blog admin. If your theme is *not* pod-enabled, you'll get a message that says Current theme doesn't have any pod locations or it is not Pod-enabled. Otherwise, you'll see the pod manager.

Toward the end of this series, I'll post showing how to make your theme pod enabled, if you're writing or updating a theme. It's not that difficult.

Template Pods

In most pod-enabled themes, there's a sidebar.cfm or similarly named file, which contains a block of code implementing the <mangox:Pods></mangox:Pods> custom tag set. It should look something like this:

...

Don't worry too much about what that does, we're just using it as a landmark. This file is where pods are rendered, so it makes sense to define some simple HTML pods here with it. You'll likely find some "Template" pods with it, and we're going to add to them. Let's say you want to add a pod with an About Me blurb. Add this block of code outside the mangox:Pods block. Techincally, it should also be inside the <mangox:PodGroup> tags. Mango supports multiple pod groups, and if your theme has more than one (more than one <mangox:PodGroup> block) you'll want to define your pod inside the pod group where you want it to be rendered.

I'm your host, Adam. I write about web development, ColdFusion, and more and more I find myself writing about Mango Blog.

If it's not instantly obvious, the part that makes Mango recognize this as a pod is the <mangox:TemplatePod id="about-me"> and everything between the tags is the content that will get rendered at the pod location.

This method is great when your pod is just some simple HTML -- perhaps embedding a flash widget or including some advertising or a graphic to link to another site. It's primary drawback is that it is only available to the skin/theme you code it into. If you switch themes, you need to copy it to your new one. Obviously that's not too difficult, but it is something you should be aware of.

Next time, I'll cover writing a plugin that adds a pod.

Posted in Mango | 3 Responses February 23 2009

Graduation

It was with a great deal of fondness and appreciation that I submitted my resignation from Perficient last week.

I started with a small consulting firm by the name of E-Tech Solutions and based in West Chester, PA in December of 2005 -- the 12th, to be exact; that's how fondly I remember it! -- and since then my life has been in a state of constant change and growth (in more dimensions than one!). To be perfectly honest, I thought I was a damn good ColdFusion developer when I applied there -- and it turns out I had a lot to learn.

I had no idea there were ColdFusion conferences, certifications, publications and mailing lists, and an enormous community of bloggers, twitterers, podcasters, and open source developers. That's a lot of media to try and absorb and keep straight, so it's no surprise that about the time I learned about these things is when I became an RSS fiend. I still whip out my iPhone to check up on bloglines at the oddest times...

When I wasn't working on client websites, I attended CFUnited in both 2007 and 2008, learned Model-Glue and ColdSpring in my free time, wrote a few open source projects myself, and got certified for ColdFusion 7. I've had my eyes opened to the beauty and importance of frameworks and design patterns.

... And there's so much more that if I wrote about it all you would drown in a sea of hyperlinks.

And I owe it all to one person: Chuck McElwee.

Chances are you don't know him. He had one article published in the CFDJ back in 2002, and used to chirp in on CF-Talk occasionally, but otherwise isn't really that involved in the ColdFusion community. He was my boss at E-Tech and he showed me that there was so much more to ColdFusion than me and the documentation vs. the world. (Although, for what it's worth, the documentation is so good that I would bet on us. ;)

When E-Tech was purchased by Perficient in early 2007, and with the economy starting its downward spiral, Chuck and I were fortunate enough to keep our jobs and continue working together. A large portion of E-Tech's business was ColdFusion consulting -- and to a lesser extent, hosting our clients. While CF made up roughly half of our business (by my own estimate) the other half was Java, .Net, Sharepoint, and other Microsoft solutions. It was these other competencies that Perficient was most interested in, and so ColdFusion became the proverbial red-headed step child.

ColdFusion consulting gigs continued coming in for a while -- and still do, to some extent -- and I've had plenty to do and lots of opportunities to hone my C# skills, but as I'm sure many consulting firms are dealing with right now, billable hours are a little bit scarce no matter what technology you're talking about.

Consulting has taught me how to work at break-neck speed and how to help a client find a cost effective compromise between the solution they want and what they want to pay for it. But most of all, consulting has taught me that consulting is not a business I want to be in if I can help it.

I will always look back and remember E-Tech and Perficient as the true foundation of my career in web development. I only wish I could bring some of the excellent people I had the opportunity to work with along the way with me.

So where am I going? What does the future hold for me?

I have accepted a position at the University of Pennsylvania's Wharton School of Business.

I'm excited about the opportunity to work in an environment where extra time spent learning something new is considered a valuable effort; where opportunities exist for me to learn Flex, AIR, and other related technologies; and to work with some great minds (Sorry if there are others I didn't link... I just don't know about your blogs yet!) in what I'm told by many is a great program.

I am not taking Terrance Ryan's vacant position, but he did mention to me who he's pulling for as his replacement. ;)

I see so many opportunities and things I want to take advantage of in my future, and this job feels like the right way to start. Here's to the next step.

Posted in ColdFusion | Misc | 4 Responses February 16 2009

Ask a Grokker: Can I change CF Client Variables with JavaScript?

Yesterday, Ray posted Ask a Jedi: Using ColdFusion Ajax to set Client Variables. Now, far be it from me to steal from Ray -- but what it looks like is that the question asker also posted his question to Stack Overflow; and after composing my response there I decided it would make a good blog entry too.

As it turns out, Ray's response is really clever. I'm quite fond of it, actually. But I still think mine is a bit more robust and closer to what you might call the "right" way to do it.

The question, to save you the clicking if you haven't seen either of those two pages, was how to get and set ColdFusion client variable values with JavaScript. As for dependencies, my solution uses jQuery and the returnFormat parameter added in ColdFusion 8.

What you want to do is write what would be called a Client Facade

ClientFacade.cfc: try { client[arguments.name] = arguments.val; return(true); }catch (any e){ return(false); } if (structKeyExists(client, arguments.name)){ return(client[arguments.name]); }else{ if (len(trim(arguments.defaultVal)) eq 0){ return(''); }else{ return(arguments.defaultVal); } }

And to use this component, you need to write some client-side JavaScript. As I said before, I used jQuery -- because I never leave home without it.

test.cfm: foo: $(document).ready(function(){ //attach functionality to our alert button $("#alertValue").click(function(e){ var clientVal = 'initialdata'; $.getJSON( 'clientFacade.cfc', { method:"get", returnFormat:"json", name:"foo" }, function(d){ clientVal = d; alert(clientVal); } ); //prevent the button from doing anything else e.preventDefault(); }); //attach functionality to our set button $("#setValue").click(function(e){ var success = false; var valu = $("#foo").val(); $.getJSON( 'clientFacade.cfc', { method:"set", returnFormat:"json", name:"foo", "val":valu }, function(d){ success = eval(d); if (!success){ alert('Failure'); } } ); //prevent the button from doing anything else e.preventDefault(); }); }); Note that I'm using "xscript" instead of "script" tags so that Mango will allow me to post it.

This code remotely (via AJAX) accesses ClientFacade.cfc to send data back and forth. It lets you specify a default value when getting, instead of dealing with non existence.

We start with a few simple form fields: a textbox, a button to save the value, and a button to get and alert the value. To demonstrate that it really is working over AJAX and not just reloading the page faster than can be perceived, you could simply CFDump the Client scope on the page. This would show that the values in server memory are changing without the page reloading.

Then, some click event handlers are binded to our buttons that use jQuery's getJSON method to interact with the server, and the return data is managed with anonymous callback functions.

One final note: Notice that in the SET operation, I'm quoting the variable name:"val":valuThis is because "val" is a JavaScript reserved word. I should have thought of that when writing my CFC, but I didn't, and this is how you get around the issue. (Or just rename the CFArgument, but who has time for that?)

Posted in ColdFusion | JavaScript | 3 Responses February 13 2009

Installing ColdFusion 8 On Windows Vista and IIS 7

There are lots of other guides out there that explain how to install ColdFusion on IIS7, but I haven't found any specifically for ColdFusion 8. Not much is different from the CF 7 guides.

To be honest I had high hopes and expected ColdFusion to not have any problems installing out of the box, so first I enabled IIS and installed CF. When that didn't "just work" I went looking for information.

I ended up working from this guide, and did everything there that I hadn't already done. For some reason, I still got an error, which I'm now wishing I had taken a screenshot of before I fixed it. I've tried breaking my installation to get it back, but can't get the exact same error message. If memory serves, it just said, "Server Error" and had a single line of meaningless IIS information under that. (So you're not missing much...)

Some more googling gave a hint, but not a definitive answer, that what I needed to do was use the Web Server Configuration Tool.

So start that puppy up:

(Yes, I use the kitten as my icon. Got a problem with that?)

And that brings up this bad boy:

Notice that there are no configured web servers. That is a pretty big clue, right there. (Facepalm, anyone?)

So we're going to ... you guessed it ... click the "Add..." button. And that brings up this mofo right here:

The only change I made on this screen was to check "Configure web server for ColdFusion 8 applications" -- the rest were the default settings. There are a couple of settings available by clicking the "Advanced..." button that I'm not sure about, so I left them at their default settings as well.

I chose the default settings because I don't do anything fancy on my local machine. I don't have the need to run multiple instances of ColdFusion, nor configure anything special web-server-wise. I'm a vanilla-install kind of guy. 

Click OK, Exit the Web Server Configuration Tool, and you're off and running.

Posted in | 4 Responses February 11 2009