(Tutorial) Let Template.php Eat Static
Tutorial : Let Template.php Eat Static
-
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:
THEMES/SPAGETTI_MONSTER/TEMPLATE.PHP
<?php
function spagetti_monster_page($content) {
// determine weather the page is a node view, or edit
switch(arg(0)) {
case 'node':
if (is_numeric(arg(1)) && (!arg(2) || arg(2) == 'view')) {
$body_class = 'node_view';
}
else if (arg(1) == 'add' || arg(2) == 'edit') {
$body_class = 'node_compose';
}
Courtesy : nicklewis.org
- guru's blog
- Login to post comments
![Drupal-6-Book-[Building Powerful and Robust Websites with Drupal 6].jpg](http://www.drupalranch.com/images/Drupal-6-Book-[Building%20Powerful%20and%20Robust%20Websites%20with%20Drupal%206].jpg)