Custom node-x.tpl.php only works for some content types?

seaneffel - July 7, 2009 - 17:44

I'm working on a theme that I adapted from Tech and updated to Drupal 6.

When I edit my node.tpl.php file to theme the node output, it only affects a few content types rather than all.

When I edit the node.tpl.php file, only a few of the content types show changes (for example, blog, story and page). The other content types that are not affected have no good reason. They are not special content types that come with special modules.

There are no other custom node-x.tpl.php files in the folder, in fact I have to create custom node-x.tpl.php files to override the output of the other content types. This is a drag.

The affected content types sometimes change when I add new content types.

I've flushed my theme registry and dumped all my caches.

What could be going on? Is there some secret place I haven't flushed yet that still has old pieces of old themes squirreled away?

What's an example of a

nevets - July 7, 2009 - 17:57

What's an example of a customization that does not show for all content types?

Examples

seaneffel - July 7, 2009 - 18:06

Here is one content type called "article" that is properly affected by changes to node.tpl.php:
http://www.cctvcambridge.org/node/21037

Here is another content type called "blog entry" that is NOT effected by changes to node.tpl.php:
http://www.cctvcambridge.org/node/21038

The biggest difference that tells me it's not working is the position of the terms region. The first example shows terms at the bottom, the second example shows terms at the top with some kind of image icon.

I am guessing you pasted the

nevets - July 7, 2009 - 19:32

I am guessing you pasted the url's reversed (21027 looks like a blog entry).

Going through the blog, some (most?) show the terms on top.

Are you using a sub-theme?

How many/which node*.tpl.php do you have?

Does you template.php have a hook_preprocess_node() function?

Are you using the core taxonomy module?

Are you using the taxonomy image module? If not, where do the images come from?

Answers

seaneffel - July 7, 2009 - 20:03

Actually, you just pointed it out, that both links above are blog entries (of the content type "Blog entry"). I don't know why they don't behave the same way.

I am not using a sub-theme.

I have the following node template files in the theme folder, and I only need to specially theme these two unusual content types:

node.tpl.php
node-video.tpl.php
node-profile.tpl.php

My template.php does not call a hook_preprocess_node() function, should it? I've never used it in the simple bloggy themes that I've made or updated before. Are we talking about this: http://api.drupal.org/api/function/template_preprocess_node/6?

This is the core taxonomy module. I am not using the taxonomy image module, I think the folder-like icons associated with the term links are being pulled from my theme's image folder. But there is no CSS in my template that calls to those images - this is my problem as it seems the default node.tpl.php is being called from somewhere else that is not my theme.

Even weirder, here is one

seaneffel - July 7, 2009 - 21:00

Even weirder, here is one blog roll for one user where each of the nodes render with a different node template even though they are all the same content type.

http://www.cctvcambridge.org/susan

Note the first node at the top of the page and it's terms list, then compare to the rest.

Not using my custom theme

seaneffel - July 7, 2009 - 21:28

Definitely not using my custom node.tpl.php, and not using the default node.tpl.php in my modules/node/ dir.

Organic Groups

seaneffel - July 7, 2009 - 21:09

I think the organic groups module is messing with me.

It seems as if nodes in OG groups do not respect the theme's node.tpl.php. I don't know where it's getting the template information, though, since it's not the custom theme and it's not the ../modules/node/node.tpl.php files.

Is that even possible? I'll take it to the OG issue tracker and see what turns up.

Any thoughts?

Problem solved

seaneffel - July 7, 2009 - 21:30

Organic Groups ships with a custom theme override for any node that is posted inside a group. That file lives at:

../modules/og/theme/node-og-group-post.tpl.php

So to solve my problem I duplicated my own custom node.tpl.php and named it node-og-group-post.tpl.php. This overrides OG's override of the default node template for a post in a group.

My collection of custom node templates now includes:

node.tpl.php
node-video.tpl.php
node-profile.tpl.php
node-og-group-post.tpl.php

I've got to do some work on the video template and the og-group-post template to make them work together rather than against.

I'll open up some discussion about this over on OG's tracker, I think this isn't how they really want it to behave? Maybe it is.

Anyway, problem solved, and thanks for asking me these leading questions. They were enormously helpful.

 
 

Drupal is a registered trademark of Dries Buytaert.