ColdFusion Implementation of Virtual Merchant

April 8th, 2008

CF Webtools works on plenty of e-commerce sites. Some generate only a trivial amount of revenue and others generate millions every year. The most common implementations we see and deal with are authorize.net and paypal. Both have very standard APIs and a feature list that is continuously expanding. Recently I was given a project which required implementing Virtual Merchant into Site Director and Farcry. It also required the ability to use multiple merchants through the same implementation in Farcry. Here’s what I did…

Read the rest of this entry »

Javascript Popup with graceful fallback

March 26th, 2008

I’ve struggled with popups for some time now. I’ve never really found a good way to handle popping up a new window when clicking a link. Sure, there is the target=”_blank” method but I’ve heard that in XHTML1.0 that is not actually valid. That tells me that browsers can still handle this but might not sometime in the future (or it might end up being included in some kind of quirks rendering mode in the future). A standard Javascript popup is another option but is too easily disabled.

This method will actually do both by creating an event handler.

Read the rest of this entry »

dmFlash Technique

March 19th, 2008

I’ve had some requests that I blog a dmFlash technique that I use in both version 3 and verion 4 of Farcry. This sounds much more glamourous than it actually is. I really just use a container with a handpicked rule but here are the details you will need to use this for yourself:

Read the rest of this entry »

Custom contentObjectGet Widget

March 17th, 2008

Something about Farcry has bothered me for a while. It is difficult to link to content programatically, especially if you have a navigation node with multiple content items under it. For example, I have an application that I was writing which contained a calendar and a registration piece. Each was a separate dmInclude under the same dmNavigation node. So, how do I create a “Register Now” button from the calendar to the registration piece programmatically? Sure, I could hard-code the objectID but that just wasn’t cutting it for this. Sure, it would work, but would be easily broken. If the registration piece was ever deleted and re-created, there would be a new UUID for it and the user would not be able to recover the functionality without editing code or the database record. So, I came up with a better solution…

Read the rest of this entry »

MS SQL IF EXISTS Technique

March 13th, 2008

I’ll be the first to admit that I’m not the greatest when it comes to database design, optimization, even query code when it comes right down to it. Sure, I can do the standard CRUD things withough a problem but really digging into a database is not my cup of tea. So, when I came up with something actually usable, I had to post it :) So, on with the shameless self-promotion…

So, I am using an IF EXISTS … ELSE block for an INSERT/UPDATE query and was having an issue with the message handler. Yeah, I could have added some additional ColdFusion logic, but who wants to do that??? I thought, It’d be really great if the query would give me back the results of what action was actually taken. So, Here’s the original query:

<cfquery name="addUpdate" datasource="#application.CaseInfoDsn#">
	IF EXISTS (		SELECT 	AreaCode
					FROM 	area_codes
					WHERE 	AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.originalAreaCode#">
			  		OR		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.AreaCode#">	)
		BEGIN
			UPDATE 	area_codes
			SET		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.AreaCode)#">,
					State_Region = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.State_Region)#">,
					Description = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.Description)#">
			WHERE 	AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.originalAreaCode#">
			OR		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.AreaCode#">

		END
	ELSE
		BEGIN
			INSERT
			INTO 	area_codes
					(
						AreaCode,
						State_Region,
						Description
					)
			VALUES
					(
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.AreaCode)#">,
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.State_Region)#">,
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.Description)#">
					)

		END
</cfquery>

And Here’s my addition:

<cfquery name="addUpdate" datasource="#application.CaseInfoDsn#">
	IF EXISTS (		SELECT 	AreaCode
					FROM 	area_codes
					WHERE 	AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.originalAreaCode#">
			  		OR		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.AreaCode#">	)
		BEGIN
			UPDATE 	area_codes
			SET		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.AreaCode)#">,
					State_Region = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.State_Region)#">,
					Description = <cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.Description)#">
			WHERE 	AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.originalAreaCode#">
			OR		AreaCode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.AreaCode#">

			SELECT	TOP 1 'upd' AS actionTaken
			FROM	area_codes
		END
	ELSE
		BEGIN
			INSERT
			INTO 	area_codes
					(
						AreaCode,
						State_Region,
						Description
					)
			VALUES
					(
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.AreaCode)#">,
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.State_Region)#">,
						<cfqueryparam cfsqltype="cf_sql_varchar" value="#trim(form.Description)#">
					)

			SELECT	TOP 1 'ins' AS actionTaken
			FROM	area_codes
		END
</cfquery>

After each action (Insert or Update) I select a random string with a random alias which I can then use for my message handler. Hopefully someone else out there thinks this is cool because I sure do :)

Big Burger

February 29th, 2008

I don’t know why but the voices inside my head that are supposed to tell me when to stop have stopped talking. Now there’s nothing to stop me from going overboard.

To illustrate this point, I give you exhibit A. Exhibit A is a photograph from a recent fast food outing at Fuddruckers (that’s a burger joint if you don’t know). They offer the normal burgers but also have buffalo burgers and ostrich burgers. They also have burgers going up to a massive one pound!

Yes, your initial thought is correct. I had a one pound burger. Not only that but I had an order of fries and a huge soda along with it.

One Pound Cheeseburger: $8.00
Order of Fries: $3.00
Large Soda: $2.00
12 hours of regret: PRICELESS!

Just to give you an illustration of how big this burger was… The bun was not a normal bun, it was a small loaf of bread. It took 4 slices of cheese to cover it and 2 large pieces of lettuce.

Big Burger

CFEclipse (no need to fear)

February 27th, 2008

A lot of people that I work with are stuck on Dreamweaver and Homesite for developing ColdFusion. I can understand that since I started out using Homesite. But, it always bugged me that they were not developing updates for it and I always like the biggest and the best.

I don’t like Dreamweaver because I feel like it is too bloated for coding. It’s a great tool for design but I tend to like my editors kept pretty simple when I am coding. That’s a topic for another post. Wait, Mark Kruger beat me to it (Read Here).

Read the rest of this entry »

CSS Rounded Corners

February 13th, 2008

One thing that I’ve learned a lot about in the last year and a half is CSS. Along with any other language, there is not one right way to do things in CSS. But, there’s usually one way that will make your life in the future much easier. The trick is finding it…

Read the rest of this entry »

Farcry Typeadmin pagination trick

February 5th, 2008

I was searching through typeadmin for something unrelated to this post and found something interesting that I thought I’d share.

It often annoys me that there are only 15 items displayed per page. Show me a site that’s been live for more than a month and I’ll show you an image library with WAY more than 15 items. Usually there are more than 15 pages.

Typeadmin takes a couple of attributes that I was not aware of until today (numitems and numPageDisplay). Here are their defaults:

Read the rest of this entry »

Delete Core Webtop Links

February 5th, 2008

I ran into a situation where I wanted to re-order an entire spot of the webtop. So, how do you do that. I know how to extend the webtop using customadmin.xml, can you get rid of things the same way?

The answer is yes, using the “mergetype” attribute. Here’s how…

Read the rest of this entry »