<About />

My name is Kevin. I am a web professional living in Massachusetts. I build websites mostly using Drupal and jQuery. I use Vim even when I don't need to. When I'm not on the computer, I'm usually hanging with my wife, Melissa.

<Search />

planet drupal

Stories for drupal.org/planet

TableField Version 2.0 for Drupal 6.x

Just a quick note that I pushed TableField 2.0 for Drupal 6. The major new feature is the ability to upload CSV files to your tables. There are also a slew of UI and CSS bug fixes. Thanks to everyone who submitted issues!

In case you haven't tried it, TableField is a CCK widget that lets you attach simple tabular data to your nodes. There is also a 7.x version that lets you attach tables to any entity like nodes, taxonomy terms, etc.

New versions of TableField module for D6 and D7

I just got around to making some final commits and packaging two new versions of the TableField module. The D6 version backports the "import from CSV" functionality. The import was the most requested feature, so there ya go! You can now import any valid CSV file to any table. The D7 version adds a super convenient rebuild function using the #ajax features of the Forms API.

For those of you who haven't tried it, the TableField module lets you add tables to your nodes with a convenient input widget. In Drupal 7, you can add tables to any entity. Any help testing the new modules would be greatly appreciated!

TableField for Drupal 7!

I just released an alpha version of TableField for Drupal 7. All of the hooks are updated to use the new Field API, so now you can add tables to any Drupal entity. There were a ton of little changes required, but it seems to be working pretty well. Any help testing would be greatly appreciated :)

New Version of TableField Released

I finally got around to committing another round of fixes for the TableField module. It's a relatively simple CCK widget that allows you to add tabular data to a node. 6.1 takes care of one critical issue, one minor issue and some feature requests. I plan on spending my code sprint time at DrupalCon creating a Field version for D7.

Thanks to everyone who tested and submitted issues!

The danger of "q=$1"; or, why you shouldn't ignore Drupal 404 errors.

Drupal makes your life very easy, but that's no excuse for being lazy. While profiling scripts today, I ran into something that, for whatever reason, never clicked before. I was running Xdebug and KCachegrind on some complex pages to get an idea where I could optimize. Xdebug has a profiler built in that creates files digestible by something like KCachegrind. With profiling on, you get a profile dump file for every PHP script you run. You can in-turn open that file with KCachegrind to get some helpful analysis.

Profiling is a great way to expose those problems that I often ignore...

Using Syslog Module and Splunk to Rock Your Reporting World

Drupal's Syslog module is one of the core modules that I find is often overlooked. On a high traffic site, it's generally a good idea to reduce the db traffic as much as possible. Besides, since the database logging doesn't rotate/archive logs, it is only marginally helpful. So, while you need watchdog, it can quickly bite you in the... sorry, bad pun, but you get the idea. The good news is that we can still log all of these helpful messages in a flat file using Syslog and do some insanely cool reporting using Splunk.

Drupal, jQuery and $.ajax() easyness.

So, I've been remiss in my blogging as of late. It's not for a lack of ideas though, so I'm going to jump right back in with something cool that I've been using a lot lately. Once again, I'm just astounded at how insanely easy jQuery makes my life. I've been reading Resig's book on the train this week and the main thing I'm learning is just how important it is to have Javascript frameworks like jQuery. There are so many nuances between major browsers - even the "modern" ones - that it would be ridiculous to try and account for them yourself when these frameworks already do such a great job.

I've written before about doing modals using the popups api and it sounds like there is some goodies in ctools. Though, sometimes you just need laser precision to accomplish one specific task to meet a clients requirement. In these cases, I'm not at all opposed to writing a quick module.

Let's say you need a really simple module that provides a link to trigger something on the back end of your site and returns a response without a page refresh. This type of thing is super common these days and jQuery makes it oh-so-simple to implement.

Read on for the code...

Adding help text to your Drupal forms using the Popups API

It seems fairly often that I put links into Drupal help text. It's a great way to show some extended descriptions or direct people to administrative options. The only annoying thing is that it really disrupts the UX. If you are entering a new node, you risk leaving an unsaved form. If you use target="_blank" then you risk confusion by having multiple windows open. So, after reading Gábor's post on D7UX overlays I decided to try out the Popups API module to solve this annoying problem.

So, now I am absolutely in love with the Popups API. It provides a great way to show contextual help and even let users execute administrative forms without losing their place. For example, I've run into a few situations where I'm using a CCK nodereference field and thought it would be awesome to create the referenced node without leaving the /node/add form. Now it becomes simple - the Popups API allows you to create an elegant javascript popup that doesn't have a negative effect on the UX. The popup can contain any page content on your site - a new node/add form, a custom page, etc. If you want to get crazy, you can even set up the popups to refresh or effect the parent page.

For example click here to leave a comment. [Planet Drupal readers will have to click through to my site to see this example]

The installation isn't too bad, but make sure that you check out the README.txt file that comes with the module. Once you enable the module, you will have to make sure that you have a container <div> around your $content variable in page.tpl.php - this will filter out the extraneous parts of your theme and only show the important parts in the popups. Next you have to specify the selector of that container <div> in your global theme settings. Finally, you need to do one of three things to make it work: 1) enable popup scanning on all pages (located in the admin settings), 2) call popups_add_popups() somewhere in a module callback, 3) add one of the popups classes to your anchor tag. The available popup classes will determine how the popup interacts with the parent page. Again, check out the README.txt for all of the details.

Also, be sure to watch the screencast on the Popups API project page to really see how cool this module is. You can use these popups to show any number of things. For example, you could create a wiki page that your administrators can edit, then link to that node from help text so that editors can maintain their own help text with notes. You could even build administrative views with bulk operations, or link to a user creation form. If you have ever had someone ask: "can I do this without leaving the page?" then this is a great module for you.

The coolest part is that this doesn't even scratch the surface of what you can do with these popups. It's a very exciting time for Drupal UX and I'm totally excited to see these things find their way into core.

Drupal/Vim users, highlight your .module files

I live in Vim, but finally got tired of editing my .module files without syntax highlighting - ugh. Turns out all you have to do is tell vim what the file is so that it knows what to shade.

Make sure that the following is in your vimrc file - notice the filetype on line:

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
filetype on
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

Then place the following in ~/.vim/filetype.vim, restart Vim and you are all set!

"  ~/.vim/filetype.vim
" tell Vim what a .module file is
if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufRead,BufNewFile *.module               setfiletype php
augroup END

Creating a colorable theme

I've always been fascinated by the color module. If you've ever selected a color palette for the Garland theme, you know how cool this module is. So a couple of weekends ago I decided to buckle down and figure it all out. It wasn't the easiest module to learn, but I have to say it felt really, really good when I finally got it to work. It's not overly complicated, but there are a lot of configurations to keep track of.

I kind of liked my experimental theme, so I started using it for myself and contributed it on drupal.org as Aquanaut.

If you want to get started with the color module, I highly recommend reading this doc page. It covers all of the basics. A couple of things that I learned:

  • Format your CSS file so that multiple CSS selectors/pseudo classes are on the same line:
      /** Don't use this format **/
      a:link,
      a:visited {
        color: #336699;
      }
     

      /** Use this format instead **/
      a:link, a:visited {
        color: #336699
      }
     
  • The first color palette in the schemes array in color.inc simply defines the color picker values. If you select the default (first) color pallette, color module ignores it and loads the style.css and images from your theme directory.
  • A really easy way to create default theme images is to set up the base.png and color.inc, pick a color palette using the color module, save the changes, then copy the images from your files/color directory into your theme directory.
  • Each fill color can only be used once, so organize your base.png wisely if you need to use a color for two different image slices.

Happy theming!