I'm using the jQuery plugin Smooth Div Scroll on a site right now, and it's filling my needs nicely. The site is built on Drupal 6, and SDS requires jQuery 1.5, so some jiggery-pokery is needed to get all the right libraries in the right places. Drupal 6 includes jQuery 1.2, and the Drupal 6 version of jQuery Update only takes that up to jQuery 1.3. I had to mess with my theme's phptemplate_preprocess_page() function to make it all work. I don't think this is a common enough problem to bother posting about my specific solution, but here's the code I started with.

Once I was able to get it working on the pages of interest, Smooth Div Scroll has done a fine job.

The goal is a gallery with a smooth, horizontally scrolling image carousel, with thumbnails below for jumping directly to certain images. Smooth Div Scroll does this very well using its "moveToElement" method. The only problem is a distinct lack of smoothness — it just jumps straight to the image instead of animating.

I was pretty sure this wouldn't be difficult to fix. On line 384 of the non-minimized jquery.smoothDivScroll file, there's this line:


Just like it says, it sets the scrollable area's left position to whatever it's supposed to be directly, with no animation. To make it animate, replace that line with this:

el.data("scrollWrapper").animate({'scrollLeft', el.data("scrollXPos")}, 'slow');

Same thing, but with a "slow" animation. Nice!

I attended Drupal Camp Chicago at the beginning of December and had a great time. It was the first conference I've been to since CHI back when I was a graduate student at Carnegie Mellon's HCII. I don't go to many conferences because they tend to be so expensive, but at $25 for two days, Drupal Camp was the sweetest deal around. As they say on eBay, A+++++ WOULD BUY AGAIN.

My goal was to learn some new things, meet some of the people in the community, shake a few hands without catching the flu, and maybe try to answer some questions for people who are newer at this than I am. If there was a code sprint or some opportunity to help out with the upcoming Drupal 7, I thought I'd have a go at that as well. I was able to do all of these things!


I'm starting to build new websites with Drupal 6 now that the juiciest modules (CCK and Views especially) are nearing stable releases, but Drupal 5 is still very widespread, so I expect a lot of people will be using it for at least a matter of months, maybe years.

Drupal 6 offers a nifty and useful javascript effect on administrative tables: the table headers stick to the top of the browser window as you scroll down. This is especially handy on pages like the user permissions page with its bajillion checkboxes. Drupal 5 doesn't have this, but with a little bit of code, you can get it. I've made a little module that, when installed, will add sticky headers to the user access page in Drupal 5. It requires jQuery Update 5.x-2.0 or later.

Download Sticky Headers module »

Once you've installed and activated both jQuery Update and Sticky Headers (they're both in the User Interface package on the modules page), you should be able to look at your user permissions page (called Access Control in Drupal 5) and get a scrolling table header to help you keep your place.

Some notes:

  1. This module works by injecting an HTML class (sticky-enabled) into the table tag used for the user permissions page. The included javascript file looks for that class and does its magic.

  2. I made it work by overriding theme_user_admin_perm() from the core user.module. The function is named phptemplate_user_admin_perm(), so if you want to override that table in your theme, you'll need to make sure your function is named mythemename_user_admin_perm() or you will run into naming conflicts.

  3. With this module enabled, you can add the functionality to other forms throughout Drupal. With themeable forms, you just look for code that looks like this:

    $output = theme('table', $header, $rows, array('id' => 'whatever'));

    And in your theme where you override that function, add the sticky-header class like this:

    $output = theme('table', $header, $rows, array('id' => 'whatever', 'class' => 'sticky-enabled'));

    From there, it should just work.

  4. The colors in used for the sticky headers are hard-coded right now. If I didn't hard-code it, the background on the sticky header was transparent, which made it hard to see. So for now, it's always black on white. In the core themes, you probably won't notice.

  5. I don't think I'm going to try to add this to the Drupal repository. It's useful, but I don't know if cluttering things up with a small backport module like this is a good idea.


That about says it, doesn't it?

I was building a module for a site I'm working on, and I gave a module the same name as the current theme. One of the modules purposes was to make some blocks for the sidebar, so I included an implementation of hook_block() in the module. In Drupal development, this means you called the function modulename_block() -- if you already have a theme by this name, Drupal could also see this as themename_block(). Anyway, when I enabled the new module, all blocks on the page were gone. This is an issue other developers have seen, and the advice seems to be "don't do it".

So don't do it. I broke the block functions out into a separate module with a different name, and all was well.



Subscribe to RSS - Drupal