Adding helpful classes and links top Drupal blocks via preprocessing: first, last, odd, even, edit, configure

Drupal's ability to preprocess HTML code in your theme's template.php file is extremely helpful for theme coding and site administration.You can find excellent preprocessing scripts on Drupal.org's forums, or simply use one of the many free Starter Theme such as Zen or Basic. I personally use the Basic Theme, which does quite a lot of theming work for you.

How not to use' "Taxonomy: Term ID (with depth)" Argument

I could write a tutorial on how to use Views' two most nefarious arguments, "Taxonomy: Term ID (with depth)" and "Taxonomy: Term ID depth modifier," but I won't. There are plenty of those. Instead, I'll just tell you how not to use them.

If you're like me, you'll get very excited when you see a URL that looks like http://www.mywebsite.com/taxonomy/term1-name/term2-name. It will fool you into thinking that you can create a view which accepts infinite taxonomy term arguments, each separated with a pretty slash. Well you can't. At least, not exactly.

Simple jQuery script for swapping images on hover/rollover

Here's a little jQuery snippet that I use often. It lets you easily specify a 'hover-state' image for any html element with class 'rollover.' Just set the rel attribute to equal the rollover image, and the src attribute to equal the original.

jQuery(document).ready(function($) {

//rollover swap images with rel var img_src = ""; var new_src = "";

Example implementation of jQuery Validation plugin

The jQuery validation plugin is an excellent tool for validating forms. The online documentation is actually quite extensive, but I found it difficult to locate any example code that really showed a full implementation of the plugin with all of its methods. After a lot of collaborative work, I've written an implementation of this plugin that manages to use most of the of customizable methods.

Setting up Drush on Siteground's shared hosting environment

Just a quick note to other siteground users with ssh access to their shared hosting accounts: Drush can work via the command line in a siteground environment. Here are some specific settings that I had to include to get it to work:

~/.bashrc: alias drush='/usr/local/php52/bin/php-cli ~/drush/drush.php --php=/usr/local/php52/bin/php-cli'

~/.bash_profile PATH=$PATH:~/home/[myuser]/drush:$HOME/bin

Drush - too many levels of recursion

I'm a total linux noob. So when I tried to manually set up Drush on a Linux server today, I ran into a bit of trouble. Following the Drush instructions, I put drush outside of the webroot and attempted to create a symbolic link between the Drush directory and /usr/bin.

The drush readme instructs a noob to do the following: ln -s /path/to/drush/drush /usr/bin/drush

So, I navigated to the drush directory and tried to follow instructions: cd /var/www/drush ln -s drush /usr/bin/drush

Add a unique body class in Ruby on Rails template

After using Drupal's template.php file to preprocess html and add unique classes to various html elements, I because very dependent on page specific css classes. While building a Ruby on Rails app, I thought it would be nice to at least add in a page-specific body class. Here's a quick snippet you can use:

<% page = request.request_uri.gsub(/^(\/)?/, '') page = page.gsub(/\//, '-') %> ">

This will:

Helpful regexs for stripping extranous styling

Content migration is a pain, particularly when you are charged with copying content from an old html site into a new framework. Often times, old content comes with the baggage of inline css styling, which wreaks havoc on your pretty new site design. Here's a handful of helpful regexs that I use to strip out undeed inline styling, while still preserving the html element structure.

To strip out span tags: <span[^>]+> Follow up to strip out the close tags:

Strip out inline styling: style="[^"]+"