Drupal Articles

Content Type Madness (CTM): Symptoms, Treatment, and Prevention

[img_assist|nid=1045|title=|desc=|link=none|align=left|width=100|height=80]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.

 

Drupal Project Movers and Shakers: The D-6000

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.

A Drupal Weather Report

I had this weird idea: drupal has become so complex, with so many moving parts, that understanding the big picture is like predicting the weather. I forgot how long ago this was, but I know this would have been an accurate report:

PLANETWIDE DRUPAL REPORT [sometime in 2008]

jQuery 1.3: Part of the Big Deal

I know I'm not among the first to hear: jQuery 1.3 . Why is it worth supporting aggressively? Here's one reason:

This creates another paragraph that -- here it is -- you can click on forever to repeat the same behavior.

If that sounds freaky, look at this chart on the performance implications:

PHP5 Reflection And You

Drupal:

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.

hook_views_query_alter : alter views queries with array keys

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]);
  }
}
?>

Discussion

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.

Blueprint Vs. 960

The starter guide in my last entry practically gives you an intro to the 960 framework as well. The names are different, but the approach is the same. Though 960 is a bit more complex. .container-x, and both "first" and "last" classes (named alpha, omega, pretentiously enough).

I decided to checkup on a drupal groups thread that discussed CSS frameworks AFTER I hit publish. As it turns out, a 960 theme is on its way to drupal core.

Theme Development With Blueprint

Web Development:

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.

Is there a drupal theme?

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.

Blueprint crash course

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)


  • 1. .container sets width to 950px, and centers the content with auto margins on the side. All grid elements must be within ".container".
  • 2. .clearfix - this does the same thing as having br class="clear" below the floating elements. See the oddly named br element that doesn't need to be there.
  • 2. .span-[x] The width of the column in the grid. Numbers range from 1 to 24. A full row must add up to 24, and can also include prepend-[x], or .append-[x], which share the exact same widths, only add margins, either before or after the column. The final column always needs the class "last" so that it doesn't add its 10px right margin.

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.

A Hack for Teaching Drupal

Tags:

How Do You Teach Drupal Without Inducing Confusion/Boredom Triggered Comas? Here's a rule that has never let me down:

Never interact with the drupal site in any way during a lesson

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:

Navigate: The Next Generation Drupal Administration

Sometimes a module comes out of nowhere, and blows away everything else. I believe Navigate is one of those modules.

There are lot of factors that make it awesome:

  • It doesn't get in your way... it stays nearly hidden, as a little circle in the top left corner til you click it. Think designs that didn't foresee the need for massive admin functionality.

If you do click the the top left circle (I think its a steering wheel), you see this:

Pages

Subscribe to Drupal Articles