Introducing the Node displays module

In a previous post, I talked about pimping the CCK ui. In that post a first patch was made available for CCK, however after a long debate, we decided to commit our code as a separate module on d.o, available at After a very short development cycle, we're proud to release the first public beta version. Features included are:

  • Separated the UI for fields and displays: the order of fields isn't done anymore on the fields overview screen, they are now available on the display screen for every build mode. If you want control over the node edit form, I recommend the excellent nodeform columns module.
  • Node regions: every field can be dropped in its own region.
  • Custom build modes: that's right, create as many build modes you like via the interface or via hook_nd_build_modes().
  • Views row plugin: create lists and use one of the standard or custom build modes.
  • hook_nd_extra_display_fields(): define custom fields. The module itself defines title, author, links, body and taxonomy so far. You can implement your own hook for more fields.
  • Exclude build modes from rendering and use the node template instead.
  • Override core search results page to use node display rendering.

As you can see, lots of fine goodies, but a screencast will explain more than a thousands words. Look at this video to discover the power of this module. We also would like to invite you all to test the beta version and submit bugs, features and/or patches. Happy Node Build Mode building!

Pimping the CCK display fields UI

Ever dreamed of having a node template with only this in it: print $content; ? Well, my sandbox site currently runs a patched version of CCK which does the following: order the fields on every display, not when managing them. You are also able to render the fields in what we call node regions. Screenshots and a first patch is available at the end of this post.

Rendering fields

In the UI of CCK we all know right now, it's possible to set the order of the fields on the 'manage fields' tab. This affects the order on the node form and on the full node, teaser etc view. Since the arrival of, it's easier to have a more finer control of the node edit form and we wanted to have that same control over the full node, teaser, sticky view .. Adding a weight property wasn't that hard to accomplish. You can see that the order of fields is different in those 3 contexts on the sandbox site. We're still looking howto affect search results too ..

Node Regions

To make our themers happy, we added node regions, so it's easier for them play around with the fields while creating their views, teasers, full nodes etc. They can play with 5 regions without having to create one single template file. Only CSS, that's what they were hired for in the first place :) If you look at the sandbox site, you'll see that with those regions, a full view vs sticky looks different, only through the magic of css.

Extra fields

In the version we currently have at work, we are able to add extra fields with custom formatters. It resembles a bit like the 'content_extra_fields' hook you can currently implement. This gives us the benefit to render the title beneath an image for instance. In the next few days, we'll be looking on howto to extend that functionality in the CCK module.


We won't release this as a module or as a fork of CCK, the best way to contribute is to release a patch of course. We're still cleaning up the code a bit, but a first version is available. Apply it against the 6--2 branch of CCK - latest dev will probably work too. As soon as we think the patch is clean, we'll post it in the issue queue of CCK. In the meantime, if you have any questions or suggestions, ping us on IRC (swentel, stalski or zuuperman).


The manage fields now only manages the cck fields.

Display fields now controls the order and the region, here the full node.

Same screen, but now the sticky context.

Shot of firebug where you can see that 3 node regions are rendered.


drupal, theming, cck, planet

node_load after switching database + cck = dangerous

While everyone agrees the node_load() function and the CCK and Content module are two fantastic things, be carefull using node_load when switching your database in code. The current database you're on doesn't necessarily know which modules are activated on the other database/site and what the properties are of the node you're trying to retrieve. This all makes sense to me now, but I had to learn this the hard way spending 8 hours debugging an enormous and enoying problem where data sometimes was completely corrupted coming back.

CCK uses its own cache table to store data to gain more performance. That's fine. Let's imagine we are on site A, create our node with many properties (hence, lot's of extra cck widgets) and save this to the database. We can look at it, edit etc, it will work just fine. Now, let's switch to our second site where we have a tiny little function which simply does this:

$node = node_load(1);
db_set_active('default'); // or siteB

Everyone with a bit of Drupal knowledge will know we'll get a full node object back from the database. But there's a lot happening in the background: node_load, module_invoke_all('hook_load') invoking content_load in CCK and here's where things went wrong this afternoon. CCK has it's own hook system calling other cck widgets to know their properties and fields we associated with our node. When there's nothing cached, CCK builds it's own cached object with all existing fields etc, but when you call this from site B and say the 'filefield.module' isn't enabled, cck will not see this, thus leaving out any uploaded properties in the node object we want to retrieve (CCK will also miss other settings, but I don't want to elaborate on this to much). Yet, we have defined this filefield in site A before. What happens now in site A is simple: we view or edit our node, but we are now retrieving the cached cck object and we see missing properties ('see' is very ironic, but you get the point right?). Frustration is wat's left if you encounter this the first time.

Oh well, luckily the French fries were very good :)


drupal, cck, planet
Subscribe to RSS - cck

You are here