node-forum.tpl.php not used
brentnj - August 23, 2007 - 15:47
Hi,
It seems that the node-forum.tpl.php is not being used. I checked that the proper lines were in the template.php and style.css files. The theme used is a modified slurpee.
Any suggestions on how to troubleshoot?
If I do a view source on the forum, it shows the slurpee css not the forum css.
Thanks!!

How about showing us some of this code?
And a link to where you got the proper code to achieve this from. I know of at least two pages that explain how to achieve something like this, you might follow an out-of-date example or something that works only for Drupal 5 (by the way, I'd recommend to upgrade to 5 anyway)
Here is the code
Didn't want to post too much info. ;-)
template.php
<?phpfunction _phptemplate_variables($hook, $vars) {
static $is_forum;
$variables = array();
if (!isset($is_forum)) {
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
$nid = arg(1);
}
if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
$nid = arg(2);
}
if ($nid) {
$node = node_load(array('nid' => $nid));
}
$is_forum = ($node && $node->type == 'forum');
_is_forum($is_forum);
}
if ($is_forum) {
switch ($hook) {
case 'comment' :
$variables['template_file'] = 'node-forum';
$variables['row_class'] = _row_class();
$variables['name'] = $vars['author'];
$variables['userid'] = $vars['comment']->uid;
$joined = module_invoke('flatforum', 'get_created', $vars['comment']->uid);
$variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
$posts = module_invoke('flatforum', 'get', $vars['comment']->uid);
$variables['posts'] = $posts ? $posts : 0;
$variables['submitted'] = format_date($vars['comment']->timestamp);
$subject = $vars['comment']->subject;
$variables['title'] = empty($subject) ? ' ' : $subject;
$variables['content'] = $vars['comment']->comment;
$variables['links'] = empty($vars['links']) ? ' ' : $vars['links'];
break;
case 'node' :
$variables['row_class'] = _row_class();
$variables['userid']=$vars['node']->uid;
$joined = module_invoke('flatforum', 'get_created', $vars['node']->uid);
$variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
$posts = module_invoke('flatforum', 'get', $vars['node']->uid);
$variables['posts'] = $posts ? $posts : 0;
$variables['title'] = empty($vars['title']) ? ' ' : $vars['title'];
$variables['content'] = $vars['node']->body;
$variables['links'] = empty($vars['links']) ? ' ' : $vars['links'];
break;
}
}
return $variables;
}
function _row_class() {
static $forum_row = TRUE;
$forum_row = !$forum_row;
return $forum_row ? 'dark' : 'light';
}
function _is_forum($arg = NULL) {
static $is_forum = FALSE;
if ($arg) {
$is_forum = $arg;
}
return $is_forum;
}
/**
* This snippet tells Drupal to override the forum_list function
* and load a custom forum_list.tpl.php layout file
* in the theme folder
*/
function phptemplate_forum_list($forums, $parents, $tid) {
return _phptemplate_callback('forum_list', array('forums' => $forums, 'parents' =>$parents, 'tid' =>$tid));
}
?>
Here is node-forum.tpl.php
<?php
if ($page == 0 && !isset($comment)) {
include('node.tpl.php');
return;
}
$curr_user = user_load(array('uid' => $userid));
$rank = $curr_user->profile_rank;
$sig = $curr_user->signature;
?>
<div class="comment forum-comment comment-<?php print $row_class; print $comment->new ? ' comment-new forum-comment-new' : ''; ?>">
<?php if ($comment->new) : ?>
<a id="new"></a>
<span class="new"><?php print $new ?></span>
<?php endif ?>
<div class="comment-left">
<span class="author-name"><?php print $name ?></span><br />
<?php if ($rank): ?>
<span class="author-rank"><?php print $rank ?></span><br />
<?php endif ?>
<?php print $picture ?>
<?php if (module_exist('flatforum')): ?>
<span class="author-posts">
<?php print t('Posts:') . ' ' . $posts; ?><br />
</span>
<span class="author-regdate">
<?php print t('Joined:') . ' ' . $joined; ?><br />
</span>
<?php endif ?>
</div>
<div class="comment-right">
<div class="title"><?php print check_plain($comment->subject) ?></div>
<div class="content">
<?php print $content ?>
<?php if ($sig): ?>
<div class="author-signature">--<br /><?php print check_markup($sig); ?></div>
<?php endif ?>
<br class="clear" />
<div class="links"><?php print $links ?></div>
</div>
</div>
</div>
and style.css
body {
font-size : 10px;
font-family : verdana, helvetica, sans-serif;
color : black;
margin : 0;
padding : 0;
}
A {
color:#663333;
}
A:link:hover {
color: #8B6565;
}
A:visited:hover {
color: #8B6565;
}
A:active:hover {
color: #8B6565;
}
li a.active:link {
color: #FFFFFF;
}
li a.active:visited {
color: #FFFFFF;
}
.slurpee-pagetitle {
font-weight : bold;
font-size : 22px;
font-family : Verdana, Helvetica, sans-serif;
color : #663333;
}
.slurpee-toptext {
font-weight : bold;
font-size : 12px;
font-family : Verdana, Helvetica, sans-serif;
color : #000000;
}
.slurpee-searchbox {
background-color: #663333;
color: #FFFFFF;
font-family: verdana, helvetica, sans-serif;
font-size: 12px;
border: 0px;
border-style: solid;
border-color: black
}
.slurpee-boxtitle {
font-weight : bold;
font-size : 11px;
font-family : Verdana, Helvetica, sans-serif;
color : #FFFFFF;
background-color: #663333;
border: solid 0px #000;
}
.slurpee-boxcontent {
font-weight : normal;
font-size : 11px;
font-family : Verdana, Helvetica, sans-serif;
color : #FFFFFF;
background-color: #663333;
padding-left: 5px;
padding-right: 5px;
border: solid 0px #000;
}
.slurpee-centreboxtitle {
font-weight : bold;
font-size : 18px;
font-family : Verdana, Helvetica, sans-serif;
color : #FFFFFF;
background-color: #663333;
padding-left: 5px;
padding-right: 5px;
border: solid 1px #000;
}
.slurpee-centreboxtitle a {
color : #FFFFFF;
text-decoration : none;
}
.slurpee-centreboxcontent {
font-weight : normal;
font-size : 12px;
font-family : Verdana, Helvetica, sans-serif;
color : #000000;
background-color: #FFFFFF;
padding-left: 5px;
padding-right: 5px;
border: solid 0px #000;
}
.slurpee-postedby {
font-weight : normal;
font-size : 11px;
font-family : Verdana, Helvetica, sans-serif;
color : #000000;
background-color: #FFFFFF;
border: solid 0px #000;
}
.slurpee-readmore {
font-weight : normal;
font-size : 11px;
font-family : Verdana, Helvetica, sans-serif;
color : #000000;
background-color: #FFFFFF;
border: solid 0px #000;
}
.user-login-block {
font-weight : bold;
font-size : 10px;
font-family : Arial, Helvetica, sans-serif;
color : #FFFFFF;
}
H3 {
font-style : normal;
font-variant : normal;
font-weight : normal;
font-size : 14pt;
font-family : Arial, Helvetica, sans-serif;
color : #000000;
background-color : transparent;
}
.slurpee-commentcontents {
font-style : normal;
font-variant : normal;
font-weight : normal;
font-size : 12px;
font-family : Verdana, helvetica, sans-serif;
color : #000000;
background-color : #ffffff;
}
.slurpee-commentheader {
font-style : normal;
font-variant : normal;
font-weight : bold;
font-size : 12px;
font-family : Verdana, helvetica, sans-serif;
color : #000000;
background-color : #FFFFFF;
}
.slurpee-box {
border: solid 0px #000;
}
.slurpee-sidecol {
font-style : normal;
font-variant : normal;
font-weight : normal;
font-size : 12px;
font-family : Verdana, helvetica, sans-serif;
color : #FFFFFF;
background-color : #663333;
}
.slurpee-sidecol A:link { color: #FFFFFF; }
.slurpee-sidecol A:visited { color: #FFFFFF; }
.slurpee-sidecol A:hover { color: #FFFFFF; }
.slurpee-midcol {
font-style : normal;
font-variant : normal;
font-weight : normal;
font-size : 12px;
font-family : Verdana, helvetica, sans-serif;
color : #000000;
background-color : #FFFFFF;
}
.slurpee-smalltextatbottom {
font-style : normal;
font-variant : normal;
font-weight : normal;
font-size : 10px;
font-family : Verdana, helvetica, sans-serif;
color : #000000;
background-color : transparent;
}
.calendar a {
text-decoration: none;
}
.calendar td {
padding: 0;
border-color: #888;
}
.calendar td div {
padding: 0.4em 0;
}
.calendar .row-week td a {
padding: 0.4em 0;
}
.calendar .day-today {
background-color: #69c;
}
.calendar .day-today a {
color: #fff;
}
.calendar .day-selected {
background-color: #369;
color: #fff;
}
.calendar .header-month {
background-color: #bbb;
}
.calendar .header-week {
background-color: #ccc;
}
.calendar .day-blank {
background-color: #ccc;
}
.calendar .row-week td a:hover {
background-color: #fff; color: #000;
}
.forum-comment {
float: left;
width: 95%;
}
.comment-left {
width: 10%;
float: left;
font-size: 11px;
margin-left: 5px;
}
.comment-left .picture {
float: none;
}
.comment-right .title {
font-weight: bold;
font-size: 12px;
margin: 5px 0 15px 12px;
display: block;
float: left;
}
Too much is better than too little info
But in your case, the style.css code is absolutely unnecessary, I assume that style.css itself is being loaded all right? It's just your node-forum.tpl.php that isn't being used. So, we don't need to know the code of your template file either, just the part of the code that's responsible for loading the template file, which can be found in your template.php
Not sure where you got this code from, but I would start with some debugging here, print out the content of $is_forum and $hook just before the switch. But I'm not really sure what these two lines here should do:
<?php$is_forum = ($node && $node->type == 'forum');
_is_forum($is_forum);
?>
Looks more like there's something wrong with those, the whole $is_forum looks a little bit strange to me anyway and how it is populated, the if clauses before that look also a bit strange and need to be right (e.g. how do your paths for the forum look like) but I'm not too proficient with php myself.
Any chance you can direct us to the place where you got that code from? Or did you yourself develop the function?
template.php not used too??
I tried to print the contents of $is_forum and $hook just before the switch but did not see the output. So I created some syntax errors in template.php just to check to see if it was used and the site still works fine.
I got the source code from the flatforum module. But did modify the slurpee theme file a bit.
template.php should work
strange but template.php should really work just fine. Have you tried to use your code with another theme? Shouldn't be too difficult to copy and paste this part plus you node-forum.tpl.php into another theme.
Are you actually working on the template.php that is inside your slurpee theme folder?
Correct folder
Yes, I am modifying the one in the slurpee folder.
Assuming a syntax error in the file would cause a problem, when does the template.php file actually get loaded?
Strange
And you're sure you upload the files and no cache is active?
Can you try out the code with a different theme then?
.theme
so the slurpee theme uses .theme rather than the node.tpl.php structure.
can it still be done?
In which case I would forget about this theme
As I said before, update to Drupal 5 and forget about this. It won't be long until Drupal 4.7 won't be supported any more and then you're at serious risk with your website.