I've been using template suggestions in a lot of projects recently and they seem like they would be a good addition to Clean theme. Here's the code I've been using:

function phptemplate_preprocess_node(&$vars, $hook) {
  $node = $vars['node'];

  // add node template files for node-type-nid, node-type-teaser, node-type-prevew
  $vars['template_files'][] = 'node-'. $node->type .'-'. $node->nid;

  if (!$vars['page']) {
    $vars['template_files'][] = 'node-'. $node->type .'--teaser';
    $vars['template_files'][] = 'node-'. $node->type .'-'. $node->nid .'--teaser';
  }

  if ($node->op == 'Preview' && !$vars['teaser']) {
    $vars['template_files'][] = 'node-'. $node->type .'--preview';
    $vars['template_files'][] = 'node-'. $node->type .'-'. $node->nid .'--preview';    
  }
}

Anyone see why this shouldn't be added to Clean theme?

Comments

psynaptic’s picture

I don't use this on very small sites but it certainly comes in useful on any site I need separate template files for teaser, preview and cleans up the node-nid.tpl.php files by allowing node-type-nid.tpl.php.

I really think this would be a good addition to the theme. I want more of your opinions on this before I commit. Is it bloat?

psynaptic’s picture

No one else use these?

mcjim’s picture

They are useful, to be sure, but this could be seen as bloat.
Wonder if it's worthwhile doing something with include files to allow extra features to be switched on if required...? Hmmm. That way you could keep clean simple, but allow extra features to be added by those who wanted them. That may or may not be a good idea. :)

joachim’s picture

The preview looks like bloat to me.

I implemented node-TYPE-teaser and node-teaser on a site recently, and the hard decision was: which way round do these go?

method A, from best fit to most general:
- node-TYPE-teaser
- node-TYPE
- node-teaser
- node

method B:
- node-TYPE-teaser
- node-teaser
- node-TYPE
- node

psynaptic’s picture

Method A works best for me. I was worried it might be bloat but it's quite useful.

hass’s picture

I'm also missing this... I don't need the preview, but the node-node_type-teaser and node-teaser

psynaptic’s picture

Status: Needs review » Fixed

Committed to DRUPAL-6--2. I didn't end up adding the node-type-nid as this was more for organisation than to provide an extra feature.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.