Quicktips

DrupalEasy Quicktips are short, focused posts intended to accomplish a very specific goal. Quicktips are exclusively available first via our @drupaleasy Twitter account.

Create Referenced Nodes On-The-Fly

If you use CCK's Node Reference field often, then this tip is for you.

Occasionally I run into the situation when I start adding a new node that contains a Node Reference field only to get half-way through before realizing that the node I want to reference doesn't exist yet. At that point I have to stop what I'm doing, open a new browser window, create the node I want to reference, then reload the original node's "add" form. What a hassle.

Module Development - Alternative to the "Are You Sure?" Screen

There have been several times where I've had to write a custom module that enables the site admin to make some major changes to their site. With changes like these, I want the site admin to be super-duper sure they know what they're doing, so while sometimes I use Drupal's built-in Confirm Form function, I sometimes decide to take a less-intrusive approach.

Low Hanging Fruit - Increasing Site Performance

One of the first things I look at when a client asks me "why is my web site so slow" is the admin/build/modules page (actually, the first thing I look at is the client's internet connection). It's very rare that I don't find more than a couple of modules that are enabled for absolutely no reason - sucking down precious server resources.

Here's a few that I find most often - and are usually no-brainers to disable:

    Module Development - Manually Creating Node Revisions

    If you've ever done any Drupal module development, then you've probably run across the node_save() function. This little beauty is the equivalent of the "submit" button on a node form. If you know anything about module development, you know that any module can tap into the "node save" process via hook_nodeapi(). By manually creating a node in code an saving it to the database with node_save(), you allow all the other modules on your site the opportunity to add their magic to your new node.

    Calendar Popups

    If you've used version 2 of the Calendar module, then you've probably been quite impressed with its fantastic Views 2 integration. If you're like me, then when you start using a new module, you often just enable all the little modules that comes along with it. In the Calendar module's case, this includes not only the main Calendar module, but also the "Calendar iCal" and "Calendar Popup" modules.

    Getting Started with the 960 Grid System

    If you've been following along with recent Drupal news, then you've probably heard about the 960 Grid System for laying out web pages. The associated Drupal starter theme, NineSixty was one of the stars of the recent Design 4 Drupal camp in Boston and is making some headway into possibly finding its way into Drupal 7 core.

    If you want to get kick-started on learning about 960, here are some great resources:

      Quick Way to Customize a Block's theme

      The Block Class module allows you to add CSS class names to any block on your site via the block's configuration page. This is extremely useful if you want to make just one of your blocks look a little bit different than the others.

      For example, let's say you want the header of one of your blocks to be red. Here's how you'd do it:

      1. Download and enable the Block Class module
      2. Add the magic snippet to your block.tpl.php file (see the Block Class's readme.txt file for details)