Tried this multiple times with different content types. Can't get node-content-type.tpl.php to be recognized, though I cleared caches. Wondered if this is a sub-theme issue. But there is a node.tpl.php file sitting in the austin theme root. Any ideas?

Joseph

Comments

j0e’s picture

Title: Node-content-type.tpl.php » Theming node type using Node-content-type.tpl.php

I neglected to mention that I was able to override other template files, such as block.tpl.php; just isn't working with the node template.
Thanks,
Joseph

j0e’s picture

Strange, this did happen once before, suddenly it's working for one custom content type yet still not the other. I checked the usual suspects, name of the content type etc. it's all correct... again, caches are all cleared so that's not it either. I would rather it's a problem with the content type than the theme, but I still can't figure out what's causing the lack of recognition of the node-content-type.tpl.php file.

caroltron’s picture

I tested adding a new content type of "event" and added a tpl called node-event.tpl.php and did not experience any issues. Is it possible that you removed the node.tpl.php? In D6 it is required that you have the node.tpl.php in addition to the node-contenttype.tpl.php. (I believe that this has change, however, in D7). Not having node.tpl.php in your theme will cause any other node-type.tpl.php to be ignored.

What is the name of your tpl? I'd like to reproduce your steps if I can. thx.

caroltron’s picture

Status: Active » Postponed (maintainer needs more info)
caroltron’s picture

Assigned: Unassigned » caroltron
j0e’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks Colleen, I didn't remove any of the template files. The thing is now I can't reproduce it either: suddenly, it's working for all my content types, not sure why: I assume it's nothing wrong with the theme, so I'll chalk this one up to sheer mystery. I switched hosting providers, but that doesn't seem to be the reason. Anyway, thanks for looking into it. I appreciate it very much.

Status: Fixed » Closed (fixed)

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

robato’s picture

This is happening to me as well right now. I have an underscore in my content type name. Does anyone think that may be the problem?

alanpage’s picture

Underscores in your content types are not converted to hyphens in the template suggestions for node templates (D6). In /includes/theme.inc the code uses the actual content type, but the comment suggests that underscores will be removed:

  // Clean up name so there are no underscores.
  $variables['template_files'][] = 'node-'. $node->type;

So a content type of my_content_type would produce a template suggestion of:

  node-my_content_type.tpl.php

and not:

  node-my-content-type.tpl.php

The Theme developer module (dependent on Devel, but a separate project now) showed me what the suggestions were for my node, despite what the Working with Template Suggestions (http://drupal.org/node/223440) doc page says: "Use hyphens instead of underscores for consistency." That should say, "unless your content type has an underscore in it."

Haren’s picture

This is happening to me as well right now.
My content type has undescores - and i've all possible variations. (and yes i have other .tpl.php-files that works)