how to: drupal Garland theme and Flatforum problem fix

After following all the instructions in the readme of the flatforum things didn't look good at all... and there were problems.... So I made some changes which are below....
(example of patched flatforum in use)
I used a different CSS.
I used a different node-forum.tpl.php
Also I changed the way flatforum checks if is a forum or not.. the one that came with flatforum I think it was messing up the colors on the forum if you used a custom one ... this is the patch works against drupal 5.1 (there is no more _is_forum() )
at the bottom you can download all the files in case you want to make it exactly as this forum
Instructions for the download file:
1. put the forum.css in the /modules/flatforum/ folder
2. put the node-forum.tpl.php in the /themes/garland/ folder
3. now have a choice:
* you can use the ff.patch file to patch the /themes/garland/template.php
or
* replace the /themes/garland/template.php file with the template.php provided

--- old/template.php 2006-12-12 15:31:55.000000000 -0600
+++ template.php 2007-02-26 13:17:05.000000000 -0600
@@ -41,21 +41,25 @@
function phptemplate_comment_wrapper($content, $type = null) {
   static $node_type;
   if (isset($type)) $node_type = $type;
-
+/*
   if (!$content || $node_type == 'forum') {
     return '<div id="comments">'. $content . '</div>';
   }
   else {
     return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
   }
+*/
+return $content;
}
-
/**
  * Override or insert PHPTemplate variables into the templates.
  */
-function _phptemplate_variables($hook, $vars) {
-  if ($hook == 'page') {
-
+function _phptemplate_variables($hook, $vars = array()) {
+switch ($hook) {
+    case 'page':
+      if((arg(0) == 'forum' || $vars['type'] == 'forum' || $vars['node']->type == 'forum')&& !drupal_is_front_page()) {
+         $vars['template_file'] = 'page-forum';
+      }
     if ($secondary = menu_secondary_local_tasks()) {
       $output = '<span class="clear"></span>';
       $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
@@ -66,10 +70,45 @@
     if (module_exists('color')) {
       _color_page_alter($vars);
     }
+
+    case 'node':
+      if($vars['type'] == 'forum'&&  !drupal_is_front_page()) {
+        $vars['row_class'] = _row_class();
+        $vars['userid']=$vars['node']->uid;
+        $joined = module_invoke('flatforum', 'get_created', $vars['node']->uid);
+        $vars['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
+        $posts = module_invoke('flatforum', 'get', $vars['node']->uid);
+        $vars['posts'] = $posts ? $posts : 0;
+        $vars['title'] = empty($vars['title']) ? '&nbsp' : $vars['title'];
+        $vars['content'] = $vars['node']->body;
+        $vars['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
+      }
+      break;
+
+    case 'comment' :
+      $cnode = node_load($vars['comment']->nid);
+
+      if($cnode->type == 'forum'&&  !drupal_is_front_page()) {
+        $vars['template_file'] = 'node-forum';
+        $vars['row_class'] = _row_class();
+        $vars['name'] = $vars['author'];
+        $vars['userid'] = $vars['comment']->uid;
+        $joined = module_invoke('flatforum', 'get_created', $vars['comment']->uid);
+        $vars['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
+        $posts = module_invoke('flatforum', 'get', $vars['comment']->uid);
+        $vars['posts'] = $posts ? $posts : 0;
+        $vars['submitted'] = format_date($vars['comment']->timestamp);
+        $subject = $vars['comment']->subject;
+        $vars['title'] = empty($subject) ? '&nbsp' : $subject;
+        $vars['content'] = $vars['comment']->comment;
+        $vars['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
+      }
+    
+      break;
+  }
+
     return $vars;
   }
-  return array();
-}

/**
  * Returns the rendered local tasks. The default implementation renders
@@ -86,3 +125,16 @@

   return $output;
}
+/* removes the next and previous links */
+function phptemplate_forum_topic_navigation($node){
+ if($node->type == 'forum'){
+        return _phptemplate_callback('forum_topic_navigation', array('node' => $node));
+}else{
+ return theme_forum_topic_navigation($node);
+} }

+function _row_class() {
+  static $forum_row = TRUE;
+  $forum_row = !$forum_row;
+  return $forum_row ? 'odd' : 'even';
+}

AttachmentSize
flatforum.zip3.98 KB

Did you replace the

Did you replace the flatforum.css with the forum.css or add it in addition to the flatforum folder?

replaced it

replaced it

Multiple calls to forum.css

For every post in the thread this is printed out:
<style type="text/css" media="all">@import "/modules/flatforum/forum.css";</style>
Wouldn't it be better to just print it once?

add forum.css

I agree, one forum.css is enough - I use

if($cnode->type == 'forum'&&  !drupal_is_front_page()) {
  $path = drupal_get_path('module', 'flatforum');
  drupal_add_css($path . '/forum.css', 'theme');
  ...

how to remove signature from comment box

another thing!!
since signature is automatically added to the posts you may want to remove it from the comment box before it gets added.
go to the modules/comment.module file line 1536:
should look like:

$form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE);

comment out:
  ? $edit['comment'] : $user->signature

so it looks like:
$form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment']/* ? $edit['comment'] : $user->signature */, '#required' => TRUE);