I am very new to Drupal but am creating a site with five distinct sections that are stylized differently. There is a base theme which is a sub-theme of Zen. I use the CCK to create different content types for the homepages of the 5 sections, and the different pages within each section. I also use the path module to set the paths for the different sections.

Using the sections module, I am creating subthemes for each of the 5 sections, and am running into the following issue. I create a content node of type "topic" for the homepage of each of the 5 sections (you may have guessed they are on 5 different topics). I then want to use node-topic.tpl.php to set specific display parameters for these nodes of type topic.

Here is where the problem comes in. In the section for Topic I, The subtheme files page.tpl.php and page-node.tpl.php properly override the same files in the base theme. However, the node-topic.tpl.php does not override the base theme file. Not only that, but drupal only looks for node-topic.tpl.php in the base theme directory, so even if it is absent from the base directory, and present in the sub-theme, drupal still does not see it and use it.

One more important note, especially because I don't really know what I'm doing, is that I am approaching this a bit empirically at the moment, as I don't understand exactly how these operations work. If I don't use the sections module, and display my topic homepage using the base theme, then what I noticed is that the file node-topic.tpl.php file is not used directly, but instead, the code from that file is entered into the $content variable. So in either the page.tpl.php file, or the page-node.tpl.php file, whereever the line " print $content; " is, that is where the code from node-topic.tpl.php gets inserted. This is funny to me, because the topic homepage node has body text content, which is not displayed

However, if I then use the sections module, and enable my sub-theme, the node-topic.tpl.php file is completely ignored and 1 of 2 things happens.
1) If the node-topic.tpl.php file is present in the base-theme, drupal will use the page(-node).tpl.php file(s) from the sub-theme, and then put the code from node-topic.tpl.php located in the base theme into the $content variable as a string. This happens regardless of whether the node-topic.tpl.php file is located within the sub-theme

2) If the node-topic.tpl.php file is absent from the base theme, then the $content variable instead consists of the user, date, title and body fields from the topic homepage node.

To be honest, the latter occurence makes more sense. However, I don't understand why 1) node-topic.tpl.php is only recognized in the base theme and 2) why in the base theme, the $content variable contains the code from node-topic.tpl.php as a string, rather than the user, date, title and body fields (i.e. the content) from the topic homepage node. A little direction about this would be very much appreciated. Thank you

- New guy to Drupal.

Comments

WorldFallz’s picture

If i understand you correctly, I think you've been bitten by the #279573: Themes can't use node-story.tpl.php without node.tpl.php bug. You need to have a base 'node.tpl.php' in the directory of a subtheme that uses variants.

barelytone’s picture

I appreciate the reply. I thought I understood the problem, but now I'm not sure. As a test, the node.tpl.php file was copied from the base theme directory into the sub-theme directory. However, Drupal is still only looking to the base theme directory for the node-topic.tpl.php file. Perhaps I don't understand exactly what you mean by:

"a base 'node.tpl.php' in the directory of a subtheme that uses variants."

WorldFallz’s picture

Make sure you also clear the theme registry.

And what I mean is, if you want to use a node-content_type.tpl.php file you have to have node.tpl.php in the directory as well.

barelytone’s picture

Thank you WorldFallz for your replies. I appreciate the time it takes. My theme settings rebuild the theme registry on every request as I am currently developing on my own computer. I also manually cleared the cache under the "Site Configuration"->"Performace" tab, just to be sure. Also, the sub-theme does indeed have a node-tpl.php file, although it is a direct copy of the file in the base theme. Neither of these things fixed the problem.

To further probe the issue I tried a few things. Since I am using the path module, the url for the node is http://localhost/~drupalroot/topic1. The internal url is drupalroot/node/3, and so I created a page-node-3.tpl.php which is recognized and used properly within the sub-theme directory when the node is called using /node/3 rather than /topic1.

I then created a second node titled topic2. topic1 and topic2 are both content types "topic" as specified through CCK. Using the sections module, both are directed to use the same sub-theme for topic1. This time however, /topic2 correctly triggers the node-topic.tpl.php file for use in the $content variable within the page-node.tpl.php template file. Yet, /topic1 still looks for node-topic.tpl.php within the base-theme directory rather than in the sub-theme directory.

I don't know for sure, but this may be a case of timing. The node for topic1 was created a couple of days ago. The sub-theme was added after creation, and the sections module was added and enabled after creation of this node, and after the enabling of the path module. I suppose it is possible that a bug is preventing this older node from triggering the same template files within the sub-theme, but in the end I really don't understand the problem.

In summary, there are now two nodes of content type topic. Both are directed to the sub-theme by the sections module. Both the sub-theme and the base theme have the template files page.tpl, page-node.tpl, node-topic.tpl.php files in them. However, the older topic node looks for the node-topic.tpl.php file in the base theme directory, while the newer topic node looks for the file in the sub-theme directory.

Thank you all who are taking the time to look at this. I do appreciate it.

WorldFallz’s picture

i'm happy to try and help, no worries. ;-)

I'm wondering if the sections module is interfering somehow-- I'll see if I can install it and take a look. in the meantime, maybe try the themekey module (that's what I use now)?

barelytone’s picture

Thanks for the direction. I'll give the themekey module a try and report back later to see if its working a little more smoothly.

--update
Switching to ThemeKey from Sections seems to have corrected the problem. Thank you very much for that piece of advice. What a headache for something that seems so small, but that's the life of all programmers I suppose. Thanks again, I'm back on the right track, although there must still be some conflict with the sections module.