Cheating on Drupal with CSS

January 24, 2006

I've spent the last 40 work hours or more trying to figure out how to get Drupal to display a right side bar box that says "Ann's Class - 4th Grade." It gives one pause. 40 hours? Forty hours?

Well, er, yes. But that's what happens when you get sucked in by a program like Drupal. You're fascinated and intrigued—then challenged and stimulated—and finally, wild-eyed, defiant and obsessed with beating the damn thing at its own...

Ah-hm. So anyway, there I was, side-bar-boxless. I tried displaying bits of the post information from node.tpl.php in a custom block, and actually got a little box that said "Ann's Class - 4th Grade," as nice as you please. Problem was it continued to say that on Mary's 3rd grade class pages and Joann's 2nd grade section. It was back to the drawing board.

I tried snippets, taxonomy modules, and a number of hacks of Taxonomy Context. I wrangled and wrestled code, ripping it out here and jamming in it there, and after all that work, I still didn't have a box that would display correctly on the various sections of the site. Oh, I had a box. I even had the text I wanted. I just couldn't get the text to display in the box. I ask you, what was a girl to do?

That's right. I cheated.

At pretty much the end of my tether—and way past my rudimentary knowledge of PHP—I popped open the CSS file, gave the box a little padding to prop it open, and absolutely positioned the text from one side of the page to the other. Job done. Yet even as I grinned and wiped my hands with satisfaction, I found myself glancing around a little furtively.

Would anyone notice? Would anyone realize that my clever coding was nothing more than a clumsy, cloddish PHP fake? A CSS imposter. A pile of smelly coding do-do.

I considered going back to the module and trying again to hack it into shape. But the memory was still too fresh. The pain too recent. I would live with it. Shamefully, yes, but I would get by.

Then this afternoon on the drive to pick up the kids from school, I suddenly realized that CSS had, once again, come to my rescue. And who was I to spit in the eye of a champion? Maybe a PHP purist would rather slit her wrists than hack a script with CSS. But so what? I bet a PHP purist knows a lot of PHP, too.

In my world, a hack is a hack is a hack. And until I can learn to harness the power of Drupal and PHP, the power of CSS will just have to do.