Why I killed Node, may it RIP

Myself, like many others, have always had an acrimonious relationship with the word "node". It didn't exactly get off to a good start when node presented me with a rude "wtf" moment when we first met. Things only went down hill after that, node remaining aloof and abstract, without ever just coming out and telling me what it actually was.

Things got better when Flexinode came along and I started to grasp the node more, but again there was node, right in there, even in the module name. CCK brought me relief, at last I had "content type" which was much more friendly right from the start and we have got along just fine. But, as always, node is lurking not far away, and keeps popping up in places such as Views.

Now, I am a themer and for as long as I can recall we've had node.tpl.php and, for what ever reason we've used the class .node inside this template, to style our "nodes". This I put down to a legacy thing or "thats the way its been done" conformity to the node class, and perhaps to maintain some sort of standard CSS for styling those dam nodes.

Recently I've been re-writing both Genesis and Adaptivetheme and reviewing all code, line by line, and in this questioning the concepts and use of all CSS. Anyone who as used my themes will know I like pseudo name spaced classes and like to incorporate the concept of semantic class naming, mainly driven by HTML5 and emulating HTML5 elements-as-class names.

So, today I came to the node. I've known for a long time that node had to go, and for my themes, the time is now. They question, as always, is what do I replace node with? This is answered by HTML5 which gives us the <article> element.

The article element is described as:

The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a Web log entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

I think this is about as close as it gets in HTML5 to the concept of a node in Drupal. I also tend not to think of article as in "a news paper article", but more along the lines "an article of clothing", where an "article" is a discreet object of a particular class or type.

Either way, article is far easier to conceptualize than the abstract node, and makes a heck of lot more semantic sense to me than node ever could.

So, with a somewhat heavy heart (I'll miss the little bugger) I bid farwell to the node class. Adaptivetheme 6.x-2.x will use .article and node is dead, buried and all but forgotten. Article forms the basis of a new name space in my themes and this will be the standard from now on.

Drupals internal page-node-type classes are brutally re-written to be page-article-type and there is not a single mention of the word node anywhere in the theme, the theme settings or CSS.

I cant guarantee its gone completely, some modules might throw it in there somewhere, but hey, at least for the most part my themes are now much more semantic.

Next on the chopping block is, well, .block - but thats another story and one I started working on way back with my .nav, .complimentary.complementary and .aside classes and we'll likely see more improvements on in the near future.

Screen shot showing the new article class on nodes in firebug

Last updated 24th October, 2009 - 2:20am

Authored by Jeff Burnz on