Thursday, October 9, 2008

My Pesky Drupal Bug Is Dead!

As a newbie drupal developer, I'm still learning the ins and outs of drupal development. As such, I'm still expecting to have crappy code here and there... but hopefully, not everywhere. :)

In this project I'm currently assigned to, I had this pesky bug I wanted fixed. For some reason, when I use my custom theme to save text area content, the information isn't saved in the database. But when I use the built-in themes of drupal, the text area content saves perfectly fine. Apparently, this bug only affects text areas since text field content is saved either way. It doesn't take a rocket scientist to figure out that something is wrong with my custom theme. As such, the hunt to find the pesky bug is on.

First, I created a new installation of drupal and re-installed my custom theme and modules there. After painstakingly deleting one line of code at a time in my page.tpl.php file just to identify the source of the bug, I finally found the culprit!!! In my newbie ignorance, I tried to cram all my conditions in lines and lines of spaghetti-sh code just to make the page look as I wanted it to look. Unfortunately, my custom theme's somewhat spaghetti-sh code was conflicting with drupal's ability to post and process text area content.

After consulting Randell, he suggested that I use the "Mello way". And like magic, it instantly squished my pesky text area bug. The "Mello way" is called as such because 1) its proponent is a guy in our office named Mello, and 2) it's his way of including different templates based on certain conditions. I must say, the way the code was implemented is simplicity at its finest. Hehe.

So thanks so much to my office mates, Mello & Randell. Thanks for always being there to help me in times of my drupal need. You guys are the best!!! :D

No comments: