jan 09 2012

Introducing the iToggle module

If you've never heard of the iToggle jQuery Plugin, it basically transforms checkboxes and radio buttons into slick iOS-style On/Off sliders. It is pretty awesome! Check out the plugin page to see it in action.

What started as a learning excercise to learn how to build custom Views Handlers ended up giving birth to the iToggle module.

The Module

The module creates 4 custom Views Handlers:

jan 05 2012

Conditional fields in Drupal 7 with #states

Have you ever had to create a conditional input field? For example, one field is a checkbox that reads "Do you have children?" and if the user selects "Yes", we want to show an additional input field that asks "How many?" (and if the user selects "No" the field disappears).

I ran into this in a recent project and, as usual, added some custom javascript using #after_build that did exactly that. I'm pretty sure this is a widespread practice.

dec 09 2011

Executing batch cron operations with drupal_queue

Sometimes when developing with Drupal you need to execute heavy scripts during cron, for example: your website has a "subscription" feature where users pay a montly fee to access premium content.

Without getting into implementation details, basicly we need to periodically iterate through every registered user with the subscriber role and check whether his subscription has expired or not and, if it has, remove his access, display a warning, etc.

sep 30 2011

drupal_read_record()

Today I was teaching our Junior Developer at Webdrop all about schemas and drupal_write_record() and he asked me a pretty decent question:

What's the complementary function to drupal_write_record?

By that he meant the function that retrieves a record, given a schema and a primary key.

I gave it some thought and quickly realized that there is no such function! Maybe I'm just being a stickler but not having this function just seems silly.

So I decided to go ahead and write it:

apr 17 2011

jQuery 1.5.2 with Drupal 6

That's right! All you Drupalers out there know how frustrating it can be to use jQuery 1.3.2 with Drupal 6 and the lack of an "official" contrib solution out there to fix this only makes matters worse.

I've tried a couple methods in the past but have had no luck. However, I finally came across an (apparently) 100% working method to use jQuery 1.5.2 and jQuery UI 1.8.11 Drupal 6!

The solution