Hello....
I found this and it seems exactly what I want to do: http://drupal.org/node/136647

I want to have one particular node have it's own node.tpl.php file and it's own node theme. (just so you know, I'm no programmer and don't really know php) However, when I insert this code into my template.php file (which already has a bunch in it), I get an error for the "switch" line. (and yes, I remove the php tags around it and have it inside the main template.php PHP tags)

the error I get is:
Parse error: syntax error, unexpected T_SWITCH in pathto/template.php on line 30

(note, I added the "pathto" obviously...normally the full path to template.php is there)

Any help on what I'm doing wrong?

Comments

Rob_Feature’s picture

Forget it, it was a spacing issue....I always forget that the template.php file has to be spaced just right. Thanks.

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
ElGringo’s picture

You say it is a spacing issue. Can you please elaborate on what you did to fix this? I am having the same problem and can not get it to work.

Thanks!

mooffie’s picture

Can you please elaborate on what you did to fix this?

You commit the same sin bobchristenson commited: failing to elaborate. Can we see your template.php?

(I'm, too, curious to hear what spacing bobchristenson talks about.)

ElGringo’s picture

I copy and pasted exactly what is shown on the handbook page into my template and get the error. Take it out and it is fine with no error.

Stomper’s picture

I had the same issue when copy and pasting in the code directly into the template.php file. Basically I removed the "" and the "" tags from the provided PHP code snippet (for 6.x) and it cleared the errors.

On a somewhat related topic. I am trying to start theming nodes using their NID per the code discussed earlier. I do not know where to find the NID for each piece of content on my site. I looked under the "Content" listing but found no "NID" value for each associated content.

Where can I find the NID? I need the correct NID so that I can name the the .tpl.php file correctly.

This seems like a ridiculously simple thing to do yet I am stumped and also could not find an existing thread discussing it.

Thanks

Rob_Feature’s picture

Hey Guys...
This was so long ago that, honestly, I don't remember at all what I did. However, just reading back the post my guess is that I had space AFTER my code in template.php. When putting stuff into template.php it's recommended that the closing ?> is left off the end, and just make sure there's no "blank" lines following the last bit of code in the file.

I'm pretty sure that's probably what I meant by a "spacing" issue....hope that helps!

/**
  * Bob Christenson
  * Mustardseed Media
  * http://mustardseedmedia.com
  */
XiMac’s picture

Same problem here with code and was the blank spaces trying to mod templates by kind of content:

function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'page':
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-nodetype-'. $vars['node']->type;
}
break;
}
return $vars;
}

The code run fine just "like this", but i'm pretty sure that the blank spaces was after case 'page':