Bookmark/Search this post with:
Saturday, April 14, 2007
My arch-nemisis is overly complex logic in template.php and page.tpl.php files. It seems to me that when a drupal codebase becomes brittle and unmaintainable, the culprit is usually going to be hundreds of conditional lines of php code in a template file. You’ve probably seen code like this before:
The dangers of this approach are something that cannot be explained: they must be felt first hand.
Switching args in a template.php or page.tpl.php file is like doing drugs (minus the laughs): lots of people have done it, survived, and even learned from it; but its an experience that is best avoided if you can help it. So lets see how to avoid it using static variables. (warning, you’ll need to use a module).