node-story.tpl.php Not Being Used
Hello,
Under a Drupal 6.10 with relatively recent releases of CCK, Views, Date, and Calendar, I am having a strange issue with my theme, which is a subtheme of Zen.
Essentially, node templates (e.g., node-story.tpl.php) are not being recognized in my theme directory by CCK/Views. I have, for example, a "Story" content type which I want to theme with node-story.tpl.php. Having researched this issue in the forums, I made sure that node.tpl.php AND node-story.tpl.php existed in my subtheme directory. The Devel module picked up node-story.tpl.php as a "Candidate Template," but the template is simply not being used.
1. I have ensured that the base template (node.tpl.php) exists and is in both the Zen and the subtheme directory.
2. I have ensured that the story template (node-story.tpl.php) exists and is both the Zen and the subtheme directory.
3. I have cleared the theme registry repeatedly.
4. I have used Devel to clear all caches repeatedly.
5. I have cleared the Views cache.
What else can I possibly do?
Thanks in advance

Strange, you really did
Strange, you really did everything right... are you overriding preprocess functions in your template.php? If so, please post the code.
If you make a change in node.tpl.php, do you see the effect, or doesn't that work either?
Thank you for your kind
Thank you for your kind responses.
Firstly, I am not doing too much on the preprocess side in template.php. Here is the file just in case you see something that might be causing this:
<?php
// $Id: template.php,v 1.13 2008/05/13 09:19:13 johnalbin Exp $
/**
* @file
*
* OVERRIDING THEME FUNCTIONS
*
* The Drupal theme system uses special theme functions to generate HTML output
* automatically. Often we wish to customize this HTML output. To do this, we
* have to override the theme function. You have to first find the theme
* function that generates the output, and then "catch" it and modify it here.
* The easiest way to do it is to copy the original function in its entirety and
* paste it here, changing the prefix from theme_ to agape_. For example:
*
* original: theme_breadcrumb()
* theme override: agape_breadcrumb()
*
* where agape is the name of your sub-theme. For example, the zen_classic
* theme would define a zen_classic_breadcrumb() function.
*
* If you would like to override any of the theme functions used in Zen core,
* you should first look at how Zen core implements those functions:
* theme_breadcrumbs() in zen/template.php
* theme_menu_item_link() in zen/template-menus.php
* theme_menu_local_tasks() in zen/template-menus.php
*/
/*
* Add any conditional stylesheets you will need for this sub-theme.
*
* To add stylesheets that ALWAYS need to be included, you should add them to
* your .info file instead. Only use this section if you are including
* stylesheets based on certain conditions.
*/
drupal_add_js(path_to_theme() . '/jquery.protify-0.2.js', 'theme', 'header');
drupal_add_js(path_to_theme() . '/agape.js', 'theme', 'header');
//$menu_item = menu_get_item();
//$menu_link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $menu_item['href'])));
//$use_menu = $menu_link['menu_name'];
//menu_set_active_menu_name($use_menu);
/**
* Implementation of HOOK_theme().
*/
function agape_theme(&$existing, $type, $theme, $path) {
return zen_theme($existing, $type, $theme, $path);
}
function active_first_level_menu_item() {
$trail_head = "";
$level = 1;
$tree = menu_tree_page_data(variable_get('menu_primary_links_source', 'primary-links'));
while ($level-- > 0 && $tree) {
// Loop through the current level's items until we find one that is in trail.
while ($item = array_shift($tree)) {
if ($item['link']['in_active_trail']) {
// If the item is in the active trail, we continue in the subtree.
$trail_head = $item['link']['title'];
break;
}
}
}
return $trail_head;
}
/**
* Override or insert PHPTemplate variables into the page templates.
*
* @param $vars
* A sequential array of variables to pass to the theme template.
* @param $hook
* The name of the theme function being called ("page" in this case.)
*/
function agape_preprocess_page(&$vars, $hook) {
$vars['sample_variable'] = t('Lorem ipsum.');
$vars['active'] = active_first_level_menu_item();
}
/**
* Use a slash instead of an '>' in breadcrumbs
*/
function agape_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'. implode(' / ', $breadcrumb) .'</div>';
}
}
function agape_preprocess_content_field(&$variables) {
// Some customisations for story content type
// Turn off some field labels for story
if ($variables['node']->type == 'story' && in_array($variables['field_name'], array('field_subtitle', 'field_source', 'field_date'))) {
$variables['label_display'] = 'hidden';
}
// CCK field items default to using <div>
$variables['field_list_start_tag'] = '';
$variables['field_list_end_tag'] = '';
$variables['field_list_item_tag'] = 'div';
// For some cases, change this to <ul> and <li>
if (($variables['field_name'] == 'field_headlines' && $variables['teaser']) ||
($variables['field_name'] == 'field_stories')) {
$variables['field_list_start_tag'] = '<ul>';
$variables['field_list_end_tag'] = '</ul>';
$variables['field_list_item_tag'] = 'li';
}
}
/**
* Override or insert PHPTemplate variables into the node templates.
*
* @param $vars
* A sequential array of variables to pass to the theme template.
* @param $hook
* The name of the theme function being called ("node" in this case.)
*/
function agape_preprocess_node(&$variables, $hook) {
zen_preprocess_node($variables, $hook);
$node = $variables['node'];
// Add a node-type-teaser suggestion
if ($node->teaser) {
$variables['template_files'][] = 'node-'. $node->type . '-teaser';
}
$variables['body_content'] = $node->content['body']['#value'];
// If there is an extracted teaser image, do some processing
if (isset($node->teaser_pp_img)) {
$variables['teaser_pp_img'] = $node->content['teaser_pp_img']['#value'];
}
}
/**
* Override theme_custom_local_tasks to make the css look like zen_menu_local_tasks()
*/
function agape_custom_local_tasks($primary = '', $secondary = '') {
$output = '';
if ($primary) {
$output .= '<ul class="tabs primary clear-block">' . $primary . '</ul>';
}
if ($secondary) {
$output .= '<ul class="tabs secondary clear-block">' . $secondary . '</ul>';
}
return $output;
}
Secondly, when I make a change to node.tpl.php in either Zen or the subtheme, nothing happens. It appears to be using the only other node.tpl.php, which is in /modules/views/themes! It's completely ignoring node templates in my subtheme, but it does recognize my standard Views templates (e.g., views-view-field.tpl.php, etc.) in the subtheme. Just not node templates...
How odd... I don't know how to troubleshoot this.
Maybe you can put the
Maybe you can put the following line inside agape_preprocess_node and post back the result:
dsm($variables['template_files']);Sorry I found this issue as
Sorry I found this issue as I'm stuck with Drupal not using my subtheme's node.tpl.php (or node-[content_type].tpl.php) files.
Mine says:
node-[content-type]You say "for example I have
You say "for example I have story", is it actually story or a custom content type, I ask because you must use the machine readable name, say for example you have a content type call "news story" the node tpl will be node-news_story.tpl.php, note the underscore.
You dont need the template suggestion in Zen core theme, just the subtheme.
Professional Drupal Design and Theme Services
Thanks for your response. It
Thanks for your response. It is an actual story content type... I am using the right name. As I said, even the Devel module recognizes "node-story.tpl.php" as a candidate for this exact content type output.
As for the template suggestion, I placed it in Zen in the hope that it would work, but it didn't help, so my suggestions are now only in the subtheme.
May be a silly question but
May be a silly question but under Administer › Site configuration › Administration theme any chance you have "Use administration theme for content editing" checked? (If you do the node-story.tpl.php would have to be part of the administrative theme).
this may be a silly question
this may be a silly question but where did you create your node-story.tpl.php files and how did you upload it
sometimes i catch myself after saving a copy of my node.tpl.php , i forget to add the php so it gets saved as node.tpl , without the php it doesn't work
Free Chemistry Tutoring - www.mychemistrytutor.com
One annoying habit I have is
One annoying habit I have is to save a copy in another folder that its higher up the directory structure, Drupal finds it first and never sees my suggestion in a lower down directory.... that ones had me scratching my head for a few minutes more that once :/
Professional Drupal Design and Theme Services