Articles

mar 26 2012

Image sharing the Drupal way with Imgly

Imgly is a Drupal 7 module for sharing images.

It allows you to upload images and display them in a nice custom template. It can also automatically generate short URLs for the image (based on ShURLy) and can also optionally track image view and download statistics using AJAX.

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

mar 28 2011

How to install PHP 5.2 on Ubuntu 10.10 (Maverick) and 11.04 (Natty)

I finally got around to upgrading my trusty old Karmic Koala install to the not-so-spanking-new 10.10 (Maverick Meerkat). So far so good and it looks great but the fact that it ships with PHP 5.3 made me kind of anxious to do Drupal development.

Update: This technique also works 100% for Ubuntu 11.04 (Natty)!

mar 23 2011

Installing Drupal from the command line with Drush

If you work with Drupal you've probably heard of Drush. In case you haven't, you really should! Let's dive in!

How to install Drupal from the terminal

First, download Drupal using wget:

1
wget http://ftp.drupal.org/files/projects/drupal-6.20.tar.gz

jan 11 2011

Site goes multilingual!

I'm pleased to announce that my website is now available not only in English but also in Spanish!

I haven't gotten around to translating any of my old posts yet but I'll get around to it in the next couple weeks...

Hope 2011 is awesome and catch you soon!

dec 08 2010

How to change your module's execution order in Drupal 6

Today I ran into a problem that had be baffled for a while:

I was working on a custom module in Drupal that would programatically add a short URL whenver a node is created or updated.
No biggy right? Just use hook_nodeapi and do whatever you want on the presave operation.