drupal

Changing page.tpl based on node type

Today I needed to add a new candidate page.tpl file based on node-type. I found this code snippet and modified it slightly.

function phptemplate_preprocess(&$vars, $hook) {
	switch ($hook){
		case 'page':
		  // Add a content-type page template in second to last.	
			if ('node' == arg(0)) {
				$node_template = array_pop($vars['template_files']);
				$vars['template_files'][]  = 'page-' . $vars['node']->type;
				$vars['template_files'][]  = $node_template;
			}
			break;
	}
	return $vars;
}

My tweak puts the new template in the middle of the candidate templates array so that I can still have specific page.tpl files for specific nodes. The devel module tells me my candidate files are now:

page-node-4.tpl.php < page-story.tpl.php < page-node.tpl.php < page.tpl.php

This works on Drupal 6.

Drupal 6.3

Upgrading to 6?

Drupal.org just went tits up in a very similar way that this site did when I upgrade to Drupal 6 while it was live. Perhaps they are doing the same?

Upgraded to Drupal 6.2

I just did a total seat of my pants upgrade to Drupal 6.2 here. The only special thing I had to do was go in and create a .info file for my theme. Plenty of other things aren't optimized for 6.2, but it is working.

Drupal 6.2 and more

Drupal 6.2 has been out for a bit now.

We just launched an updated version of Global Envision. It is running on Drupal now. Mostly stock modules, most of the energy spent on theme development. I used a couple of modules I hadn't used before, like img_filter and Slideshow Creator. I'm pleased with the outcome.

Now I need to learn Django so I can still have a job when Google takes over everything.

Drupal 6.1

Before I even had a chance to update many of my sites Drupal 6.1 is out. Now if CCK for Drupal 6 were just ready...

Drupal 6

Drupal 6 is out. Congrats, guys.

Drupal 6 and sequences

I am porting another site to Drupal. I am repurposing a script I used for a Drupal 5 import for a Drupal 6 import. After modifying it, I ran it for the first time and discovered the sequences table is gone. So then I looked at the node schema and noticed that nid is now auto_increment.

I'm assuming this means that the Drupal team is getting more serious about performance. Yes, that does mean a hit to portability, but I don't think many people are planning on running Drupal on Oracle any time soon. I'm pleased to see this development.

On that note, there is a free webinar "Achieving Optimal MySQL Performance For Drupal" Thursday. It looks interesting.

Drupal 5.7

Drupal 6 byline module

I need to add one extra field to a Drupal 6 content type. CCK for 6 won't be ready for a while, so I threw together a simple module that will add one extra field. It is a nice small sample of how the Drupal 6 install system works.