Fun Theming All Node Edit Forms at Once

Drupal 6 provides many avenues to modify its appearance, including ways to theme a form. Recently I themed all node edit forms at once. I will share here how I did it.

The usual route to theme a node edit form, or any form for that matter, is to grab the form ID, which is used as a theme hook, and implement a hook_theme function in template.php in the theme.

function MYTHEME_theme() { return array(
    'blog_node_form' => array(
     
'arguments' => array('form' => NULL),
     
'template' => 'blog-node-form',
    )
  );
}
?>

This lets you alter the theme registry to add a template file for a specific form. There are many blog posts that go into more detail than I do here on how to theme forms in general.

The above is useful if I want to theme a blog content type or the user registration form, for example. Most sites have at least a few different content types. I wanted to make alterations to all node forms at once and use a single template file. This involved a slightly different approach.

Correction: This next step with the theme_registry_alter example is not necessary. See comments below this post.

There is a theme_node_form theme function in Drupal, which is called by all node forms. I wanted to replace or supersede this theme function with a template. I tried to do this with hook_theme, but it continued to pick up some parts of theme_node_form in addition to supporting my template file. So it called the form array twice, causing recursion; which is not what I expected. So instead I took a colleague's suggestion and altered the theme registry via hook_theme_registry_alter(). This seemed clean and simple enough.

This takes the node_form theme hook and changes it from a theme function to a template, in sites/all/themes/MYTHEME/template.php:

function MYTHEME_theme_registry_alter(&$theme_registry) {
 
$theme_registry['node_form'] = array(
   
'template' => 'node-form',
   
'arguments' => array('form' => NULL)
  );
}
?>

This worked great. But I hear that hook_theme_registry_alter is intended for use in modules only? If you know why, please chime in with a comment. Or leave a comment on the theme registry for special cases handbook page.

And the fun part... Spiffing up the node edit form

Here is what I did. This creates two columns for the form and places all top level form fieldsets on the right.

Screenshot:

Screenshot of modified node edit form.

And here is how I did it...

Photo
Squiggy

Drupal in the Cloud (and other fun stuff) at SxSw

Just a note to all kindly Drupalists and your followers. I'll be appearing at SxSw interactive to talk about Drupal in the Cloud, sporting an updated presentation which includes info on how we're using BZR to create a "cloud platform", where all that's going anyway, plus details about our forthcoming Mercury on-demand service.

Photo
Josh

High Performance Training At DCSF!

One of the great things happening this year at DrupalCon North America — Moscone Center, San Francisco, April 19th - 21st; sign up now — is the community is organizing to offer a number of focused trainings in advance of the conference itself. For those looking to build their Drupal skills and come away with practical knowledge, the rel="nofollow">pre-conference training sessions offer solid takeaways on a number of subjects.

Photo
Josh

Chapter Three Sessions for DrupalCon San Francisco

We are all really excited that DrupalCon will be happening in San Francisco this April, and now we're really excited to help bring our Drupal knowledge to the masses. We are a part of nine different and wonderful sessions proposals for DrupalCon, focusing on design tools, designer/developer interaction, Agile project management for Drupal, Drupal in the Cloud (with our partners at Rackspace), Drupal as a product platform, how to grow your Drupal firm, and Continuous Integration & Automated Testing.

Photo
Stephanie

Design for Drupal: A Template Approach

We design a lot of websites at Chapter Three and we've developed a systemized approach using a Fireworks template to speed up and streamline the production process. This template can be used as a starting point or a finishing point, depending on the size of the project. This template does not replace our workflow, but rather enhances and supports it by ensuring that we don't miss any key elements.

Designing the "old way"

We used to design sites by creating a wireframe, and then designing a final composition of the front page, and several key sub pages.

The Problem

While the site itself looked great, the tabs did not. They stood out like a big sore thumb.

The Solution

Style all of the elements.

Photo
Nica

My Life with Panels, Vol. 1

Chapter Three is in love with Panels. A lot of people are, and with good reason. It has the power to eliminate the need for theme developers, especially with the development of Panels Everywhere.

I have recently returned to Drupal after a long hiatus and while a lot remains familiar, Panels is one of those modules that has grown into a wild, hairy beast. I can't really tell you what variants or contexts are used for, and I'm not quite sure why I have to save twice when updating anything on a panel page. There is scarce documentation about using plugins, and I wouldn't necessarily describe creating a plugin as "fun". But it's a learning process, eh?

So I'll share with you some of the best practices or problems I've encountered, and then maybe Merlin of Chaos will magically appear and comment that there is a far simpler way of doing it. Or maybe some of you have different approaches that you'd like to share or can find faults with my approach?

**EDIT** I highly recommend reading all the comments attached to this post, Merlin of Chaos did appear and explained a few things, particularly how to specify an alternate admin theme and css without doing my hack.

In this blog post I'll discuss how to make your theme aware of panels, as well as how to create a custom panel layout plugin. Read the full post here.

Photo
Farsheed

Designing for Nvidia

Chapter Three gets to work on a variety of design projects, ranging from the creation of original designs to working within an existing brand. We recently collaborated with Nvidia to do the latter, producing a top notch site for them under tight deadline in order for them to showcase their new product Tegra at CES.

Photo
Nica

Total Control 1.1 Release

Total Control, for those of you who are not familiar, is my administrative dashboard module. When enabled, it immediately gives you a panel page with panes showing some statistics on your site. These statistics include counts for the number of users, posts of each type of content, comments, vocabularies and taxonomy terms.

Photo
Jennifer