Archive Page 2

I use this blog quite a bit for documenting little quirks, bugs, work-arounds, neat things, and tutorials so that I know where I can find the solution in the future. At the same time, you benefit by hopefully not having to go through some of the same messes I did just to get to this point.

I love CakePHP so far (but still quite the noob), but my biggest gripe is the documentation. The basics are there, but there’s often too little documentation to get the novice going. From the Bakery docs, it’s not exactly clear how to perform tests on models when HABTM (has and belongs to many) relationships are involved. Have no fear, it’s doable (though not straightforward).

Hopefully you baked your MVC pieces and included test scripts to go along with them. If not, do that first. The key part to getting the tests for models that have HABTM relationships is to set-up a fixture representing the table that stores the relationship. Don’t actually set-up the test – just the fixture.


It has been an interesting month – at the same time I’m picking up CakePHP, I have a client project that uses the Zend Framework. Right out of the gates I like CakePHP better. ZF doesn’t seem quite as cohesive as Cake, so getting it set-up has been more challenging. Granted, the client’s setup is a little more complex than the standard setup, but it still seems like there’s a lot more work involved just to get things going – lots more configuration. After two days on Zend I already realize how spoiled I am with Cake.

With Cake, I’m finally starting to learn unit testing. It seems real simple in theory, and I’m sure it is once you get the hang of it, but it is tedious. I’m talking about the amount of actual work involved just getting these test cases working. My simple pleasure at the end of the day is watching the screen fill up with a bunch of green “Pass” statements… no red.


Working with a new client project this week that requires the Zend Framework. It’s not my choice of frameworks, but I’m still eager to get going on it. As I’m a bit more familiar with CakePHP, I thought it would be wise to watch a screencast or two about getting started on ZF to see what some of the main differences are. Watch them (from Mitchell Hashimoto).


Well, it’s finally out the door: the new ShopZoo.com – The online store for the San Diego Zoo and Wild Animal Park. The project was to produce a new ecommerce platform to replace the previous. Many thanks to the team for your hard work getting this out the door, especially with so many great enhancements and features to really streamline the order fulfillment and product inventory processes.


After much work and anticipation, the Environmental Lights redesign has launched. I’ve effectively been the dev project lead (not project manager) for this site (via 212Interactive) for the last year – a great experience. The goal for this redesign was to clean up some of the design and make the site easier for customers to navigate. Environmental Lights has a great selection of earth-friendly lighting solutions, including LED and CFL bulbs.


I’ve had a couple of small tasks where I’ve needed to toggle the onclick events on a page element. It was surprising how difficult it is to get a straight answer on how to do this.


function hide_field() {
my_element.onclick = function() { show_field(); };
}
function show_field() {
my_element.onclick = function() { hide_field(); };
}


Working with form check boxes can be a bit of a pain on sites with dynamic content. Saving the checked data is easy, but how do you easily save the unchecked value without manually adding it to an array from inside your code? Keep reading.

revealCMS is working great – I’m really starting to see a lot of its strengths (and, admittedly, some weaknesses) as I use it more and begin extending it. Due to how data is saved to the database, the HTML checkboxes were a bit of a problem when trying to save their unchecked state. Typically I save the post data to the object, where it is filtered and scrubbed, as necessary.Only the posted values get updated in their respective rows (makes sense, right?).

The problem is that unless a box is checked, it’s not going to be sent with the form – a problem if you have a checked box, but want to save the unchecked state.The first option is easy and probably the first solution you’d think of – write a couple lines of code for every single checkbox and set it to some default value if it’s left unchecked when the form is posted. Fine, but that takes more thinking than I want to do for something so simple, and it’s somewhat prone to error. Instead…

…the solution: Insert a hidden form field with the same name as the checkbox and the default value right before the place where the checkbox is located:
<input type="hidden" name="box1" value="0" /> <input type="checkbox" name="box1" value="1" />
What happens here is that when the checkbox is left unchecked, the hidden field’s value gets submitted, as-is. When the check box is checked, the hidden field’s POST value gets overwritten by the activated checkbox’s.
Unactivated: Hidden field’s value.
Activated: Check box’s value.

Told you it was easy!


I’m looking into new JS frameworks for frontend enhancements, and came across MooTools on recommendation from a friend. The framework has lots of cool features and seems pretty simple, but one thing I’m most impressed with is the download page. It acts just like the *nix package managers – allowing to you pick and choose which modules you’d like to download – even auto-selecting dependencies. Definitely a novel idea for the web.


The Flood website redesign has finally launched. On the back-end is the upcoming revealCMS. There are still a few bugs here and there that I want to iron-out before I make it a 1.0 release, but it’s getting there. Overall it’s been a very stable release. The only hiccups we’ve really had to date are with little server quirks and file permissions, but other than that pretty solid.

Some of my most immediate fixes are mostly in the user experience realm. Just from really using it over the last month or so, I’ve found a few areas that can be improved, or shortcuts added.

Next step: revealCMS.com upgrade.


I just received word that one of my projects just won a Davey Award for online marketing and email campaigns:

Munchkin’s Project Pink: Email a Duck, Raise a Buck!

Harley Bergsma at the UXB and I devised this brainchild together. From there he took care of project management and I took care of developing the back-end. The idea is that users can decorate their own pink duck on the site (using Flash), then forward their creation to all their friends. For each person that receives the duck and opens (don’t even have to click links!) the email five cents is donated to Susan G Komen for the Cure. One of the coolest things is that the email dynamically shows how much the duck raised (how many emails were sent) and how much the project’s running total was. If you were to come back to the email a few minutes, days, weeks later, it would continue to show fully-updated information. Rad!

In just a couple months there were over 131,000 forwards, for a total of over $6550 raised just from this part of the campaign alone.