If you are new to drupal, then this list is for you. These are some of the best of the best drupal modules. Everything from standard framework modules, to location and mapping is covered. Note that if you've been emersed in drupal for some time, than this will be "old news".
"The big three" are important enough that they deserve a category of their own. Most drupal modules worth using have integrated with one of these three. Their importance simply can't be stressed enough.


One of the first lessons they teach you at the School of Drupal Arts, Arcane Sciences and Sorcery is that a tpl.php can have dynamically generated wildcards or "suggestions". You can see this every day drupal themes: you can simply use the "node.tpl.php" file if you want only one style for a node. Where as if you want different styles for three node types: blog, story & page, you create the following files:
Obviously, this pattern exists far beyond nodes. For page.tpl.php, user/register can have its own tpl.php file:
Where as user/1/edit will be (yes -- these suggestions will remove numbers... i think... i was hung over that day in class):
This may be fine and dandy if your agenda is either to build a simple drupal theme with a few exceptions, or to build manly Texas sized drupal themes with enough tpl.php files, and duplicate html code to choke a donkey.
Old Switchy McTipplefep's trick is for anyone who:
The magic happens in your theme's $theme_name . '_preprocess_' . $theme function. Below are examples for how a theme named "example" would do it.
function example_preprocess_node(&$vars) {
$node = $vars['node'];
// only switch for story type
switch($node->type) {
case 'story':
$vars['template_files'][] = 'node-batman';
break;
}
}
function example_preprocess_block(&$vars) {
// sure why not -- we'll pass our node.tpl.php file to our block
// That's how tpl pimpin works sometimes
$vars['template_files'][] = 'node-batman';
}
*well, probably anything that uses drupal.behaviors...
Today, I was doing a few experiments on how to get several giant CCK node forms to load and submit via ajax from a single custom page.When this technique actually worked on the first try, my exact words were "no f#cking s#it..." I'm sure I'm not the first to figure this trick out, but I have had a hard time finding people who've described it. Perhaps everyone besides me figured it out ages ago -- though if that's true, I don't want to know what horrible things have driven some of you to use your current techniques.
This technique seems especially ideal for integrating any existing drupal form (especially giant CCK forms with sortable, multiple value, file fields), and the results into some highly customized drupal based web gizmo. *IT REQUIRES NO PHP* beyond whatever calls you may have to make to get dependent JavaScript files available to your requesting page. This pattern will mostly degrade to drupal's default behavior if JavaScript isn't present.
We use javascript to take what we want from drupal's default behavior, and throw away everything else.
Below, is all you need to submit a giant CCK form and have it successfully post:
//node form just happens to be the ID shared by every node form
//replace #node-form with any form ID and the results are the same
$('#node-form').submit( function() {
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// ...
}
// return false prevents the form from submitting regularly ... noob...
return false;
});
Even though the user will not be redirected or see any results of this $_POST, jquery will still follow the default redirect to node/$node->nid or return the original form with validation errors -- this is actually a good thing.
$('#node-form').submit( function() {
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// why not, lets replace our logo with the resulting node
$('#logo').replace($(response).find(.'node');
}
return false;
});
There's a few downsides I see to this technique: for one generating entire pages is totally unnecessarily; since we are simply taking contents of $(.node) from the result's full document object, why load the entire page? The answer is: the page already exists, and its one less menu_callback, loading, or godforbid form behavior altering trick that will cause bugs down the road. Its easy, it works, and all but the minority of websites would need to worry about the performance implications.
Another downside is that since we are using jQuery, we are depending on classes and ids that may eventually change. I think this is a real risk, but i think the risk can mostly be avoided by making intelligent decisions about what selectors you use. Besides, the maintenance hassle is probably still less compared to many of the alternatives.
The code snippet is cute as a button, though its handling of validation is sort of half-assed. Note that the vast majority of code is devoted to simply throwing around the response data, the jquery itself is elementary.
The mere words "multistep form" once gave me a feeling of dread. There are several techniques (arguably hacks) that enable multistep forms in drupal 6. However, if you've ever used them, you'll know that they are a not techniques for the faint of heart.
While Merlinofchaos's multistep form wizard is not for the faint of heart either, I will say I found programming the forms to be fun. The setup takes a bit of focus, but after that, writing the steps is almost too easy.
Chaos Tool's wizard.inc is distinct:

Here's a Live Demo of the Wombat Deployment tool I wrote that uses the wizard. Only impressive in how easily it was written, and how easily i could write a 3rd, 4th, 5th, or 20 steps following the same pattern [ the subject of future posts are hinted in a rogue modal.inc file in the download.]
To get started building multistep forms, follows these steps.
The full code, and detailed doc on the $form_info array will only be made available to freaks who click the "read more" link.
Content type madness is a common disease that effects drupal sites of all sizes. It is most frequently seen in drupal 5 and 6 sites, as result of content construction kit.
It is a serious, chronic disease that can result in long term damage to a site's agility, usability , and information architecture.
Treatment of content type madness is usually difficult, time consuming, and often requires the services of drupal specialists. In severe cases, treatment requires a total redesign and refresh of content. If you have never attempted to treat content type madness, BACK UP THE DATABASE BEFORE YOU TRY.
Highlight: WYSIWYG API Gets Top Spot With 97% Growth (Feb 8th - March 29th)
Ever wondered which modules' userbase was growing fastest?
With a bit of simpleXML, 2 hours of boredom, and drupal.org's usage charts, I can provide an answer. Personally I thought the results were rather interesting.
This list only includes projects that got 6000 downloads or more last week. I picked 6000, because otherwise, ubercart wouldn't show up.
The phpdocs put it kind of weirdly:
PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions and methods as well as extensions.
I prefer the notorious c.h.x.'s definition
chx: it's like this insane cool weaponset of PHP which is like totally unknown :)
Reflection is a very powerful too that lets you understand the code running in your enviroment. This is particularly important for drupal development, as so much of drupal is based on functions that call functions (e.g. hooks).
The point of this tutorial is to show you how much ass reflection can kick, in so little code. The following page finds out every menu item that calls a function hidden away in a remote file, and gives you the location of the callback function: filepath, and line number and all. Note that the vast majority of code is merely used to output the test table. Obviously, this example merely scratches the surface of useful things you could do with this api.

While building a product comparison website, I ran into a situation that required a view to sort using one of 2 possible price totals depending on a users profile: lets say "red state", "blue state". The goal was to open up the product comparison tables (order, fields, field names, and filtering questions and all), as well as the underlying data to this companies' staff, so a homebrew wasn't an option (which it shouldn't be, almost 99% of the time).
Luckily, there were only two possible prices for those products, so all I had to do was create two CCK *decimal* fields [ this is important, because text, and integer fields don't properly store or sort decimal points for prices ]. Then, on hook_cron, or a node submit, I updated the two totals based on other itemized fields.
However, how would the view know which column to sort products by based on a flag stored in the users session? There's about 5 ways to do that, so I went with the 1 minute solution:
Set up two sorts in a single view, and implement hook_views_query_alter(&$view, &$query)
<?php
function product_compare_views_query_alter(&$view, &$query) {
// fyi, anonymous sessions need a record in the user table of 0 to work at all....
if ($_SESSION['pref']['state_color'] == 'red') {
// we'll have to do the less popular red query
// which's key is [1] (weighted second in the views sort order interface)
unset($query->orderby[0]);
}
else {
// otherwise, don't do the hill billy logic at all....
unset($query->orderby[1]);
}
}
?>In theory, you could write a custom algorithm that built its own sort queries based on a criteria using this method. You could also probably alter filters, or fields. However, this isn't the only way to have accomplished this -- but its the easiest for me to stomach. Never use this method when existing views features, or view arguments, or even other views hooks may be the proper hammer for this nail.
If I learned anything, its that views a complex beast; flexible like F-22 -- an amazing piece of technology that offers tremendous freedom -- but often that freedom will cause you to crash in the ground if you don't think about what you are doing carefully.
During the drupal.org redesign process, I noticed that Mark Boulton was using blueprint. I decided to give it a spin, and used it on a drupal site for a surgeon who specializes in sports medicine. (heavy use of imagecache, nodequeue, views, books, and nicemenus). Since that project, my stance on blueprint is this:you'll take my CSS framework from cold dead hands.
Yes, and its very well made. Offers nothing except a basic grid layout that supports1,2,3 columns, a strong typographical foundation, and the conversions of various drupal elements to the blueprint styles. My "starter theme" of choice. In my humble opinion, the revolutionary advances in drupal 6 make big, bulky starter themes unnecessary.
You don't need to know a whole lot to use blueprint. Everything you absolutely need to know is in the below code example. (with notes below)
<div class="container clearfix">
<div class="span-6 append-2">
</div>
<div class="span-8">
</div>
<div class="span-6 prepend-2 last">
</div>
<br id="you-dont-need-a-br-since-clearfix-does-the-same-thing" />
</div>
And that's really all there is too it. Of course, there are many more features, that let you get perfectly centered borders that don't cause the elements to overflow, some nice typography classes, and other useful stuff that nearly any website needs. I found the best way to learn the framework was to just look at what's going on on the example pages, with firebug. Its all quite self-explanatory.
How Do You Teach Drupal Without Inducing Confusion/Boredom Triggered Comas? Here's a rule that has never let me down:
The person you teach needs to click on every menu link, fill out every form, and as they learn, its your job to start taking off the training wheels. At first, you'll have to point them to where to go to add a new taxonomy term, but make it a point to later ask them to add a taxonomy term, and see if they remember how to find it.
This "hack" works well for two reasons:
When I'm at the helm, clicking around, and "explaining concepts", its almost impossible for me to avoid inflicting a salvo of turd bombs on my hapless student. For a moment, read this: (if reading this text doesn't make you want leave this article, there's something wrong with you)
In Drupal, a node is a grouping of data, which we call fields. A node is different from a user, and block, because its content, which leverages drupal's rich nodeapi. On this page you can add, edit, and manage node types using these tabs. By clicking "edit" I can edit node settings, like whether I want comments to be threaded, or flat. Isn't that exciting? By clicking "manage", I can add new fields to my node, which can be of many types including, text, number, decimal, computed. These fields have rich set of options, including setting the maximum length, making the field required, and even entering in custom validation code for node form submits.
Not only is this a terrible way to teach, best case is that your student is completely lost (probably on something as simple as the difference between nodes, and node types, the fact that a "field" is a specific CCK concept, and not a form element), but most likely, they are not paying attention anymore. Monologues + projectors = brain death.
Don't teach them about blocks. Teach them how to put that new announcement in the right sidebar. Don't teach them about views.Teach them how to edit their press release page so that it only shows titles, and dates, and a "short blurb" field. As they gain more understanding, you'll find they naturally gravitate towards more advanced concepts. Best of all, you don't have to waste time talking about boring things that they don't need to know, or blabbering about stuff that they already understand.
Nearly everyone has a tendency to worry about asking "stupid questions" (they are never stupid questions). If a student actually has to do all tasks required to teach something themselves, they won't be able to hide the fact that they missed a critical concept. You'll know fairly quickly if you need to do a better job of explaining the admin menu and how it fits together, and the pattern it follows. You also will probably find out that they still have conceptual issues that need to be cleared up between the very similar taxonomy, block, and menu pages. You see, every little task becomes A TEST. Testing is about taking off the training wheels. Even when they *fail*, the very fact that their brain had to struggle before hand means they'll have learned something. Its uncommon for someone to fail tests like "go to the block admin page" more than 2 twice. Eventually, they'll know where to look even when they've never seen it, and you are just now introducing the concept. Just keep testing them. After all, its really a test of your teaching skills, no?
While this makes teaching and learning more challenging, they learn dramatically faster then the monologue projector methods, or constant email support alternatives. .
*There's no exceptions to anything I write, FYI. If there were a lot of variables, a situations where these rules didn't work, I'd cover them one by one. Because Drupal Planet readers love long winded tracts that refuse to take sides.