Theming the Comments in Forums

eng.anas - March 8, 2008 - 06:22
Project:Four Seasons
Version:5.x-0.7
Component:User interface
Category:feature request
Priority:critical
Assigned:eng.anas
Status:postponed
Description

hi
you had done a nice work by making node-forum.tpl.php but i notice it's only focus at the first topic of the forum, i mean first post, while comments are controlled by comment.tpl.php..
so if i want to theme the comment that mean i'll theme all comments, not only forum comments , to solve this problem i tried flat forum and advanced forum, and i found it so hard to deal with it.
any way my request is: I retheme node-forum.tpl.php, but when i try with comment i found problems such as:
how could i get posts number? i used to use this code but it wasn't work
<?php print t('Posts:') . ' ' . $posts ?>

how to put the name in comment, not with date, i want to put it above picture, i was using this code to do that <?php print $name ?> here it's not work

how to put signature. it wasn't work with me :(

the last thing links are vertical, while i need them horizontally i put this code

  <?php if ($links): ?>
    <div class="links" style="text-align: right;"><?php print $links ?></div>
  <?php endif; ?>

thnx for helping
for people how don't like div :) just like me here it's the code of node-forum.tpl.php as table not as div
IT'S NOT COMPLETE YET

<?php
    $account
= user_load(array('uid'=>$node->uid));
   
$sig = $curr_user->signature;
?>


<table border="2" width="100%" cellpadding="8" bordercolor="#3077B5">
  <tr>
          <td width="120" valign="top" rowspan="2">
           <b><?php print $name ?></b>
                            <span class="links">
                <?php print $occupation; ?><br />
                <?php print t('Posts:') . ' ' . $posts ?><br />
              </span>

            <?php print theme_user_picture($account); ?>



          </td>
          <td valign="top" colspan="2">
            <?php if ($comment->subject) : ?>
              <?php //print "<div class=\"comment-left-title\">" . check_plain($comment->subject) ."</div>"; ?>
            <?php endif ?>
            <?php if ($comment->new) : ?>
              <a id="new"></a>
              <span><b><font color="#FF0000"><?php print $new ?></b></font></span>
            <?php endif ?>
            <div class=\"comment-left\">
              <?php print $content ?>
              <?php if ($sig): ?>
                <div><font size="1" color="#999999"> ___________<br /><?php print check_markup($sig); ?></font></div>
              <?php endif ?>
            </div>
          </td>
  </tr>
  <tr>
                  <td>
                    <div class="links" align="right"><?php print $submitted ?></div>
            </td>
              <td>
                    <div class="links" align="left"><?php print $links ?></div>
            </td>
  </tr>
</table>

and here it's comment in table
IT'S NOT COMPLETE YET

<table border="2" width="100%" style="border-collapse: collapse" bordercolor="#C0C0C0" cellpadding="3"><tr><td rowspan="2" align="center" width="100px">


  <?php print $picture ?>
  </td><td>
  <?php if ($submitted): ?>
    <span class="submitted"><?php print t('!date — !username', array('!username' => theme('username', $comment), '!date' => format_date($comment->timestamp))); ?></span>
  <?php endif; ?>

  <?php if ($comment->new) : ?>
    <a id="new"></a>
    <span class="new"><?php print drupal_ucfirst($new) ?></span>
  <?php endif; ?>

  <h3><?php print $title ?></h3>

  <div class="content">
    <?php print $content ?>
  </div>
  </td></tr><tr><td height="10px">
  <?php if ($links): ?>
    <div class="links" style="text-align: right;"><?php print $links ?></div>
  <?php endif; ?>
</div>
</td></tr></table>

i hope that i was doing well thanx for helping :)

#1

derjochenmeyer - March 8, 2008 - 13:36

i would have also suggested advanced forum http://drupal.org/project/advanced_forum

but it seems hard to setup...

try the following. it wil help you figuring out how to get the sinature for example

put it in your comment.tpl.php

<?php
print '<pre>';
print_r($comment);
print
'</pre>';
?>

if you need to know more about the user you have to do a user_load(array('uid'=>$comment->uid));

hope that helps

#2

Michelle - March 8, 2008 - 14:10

'but it seems hard to setup"

There's not much to setting it up. What part are you having trouble with?

Michelle

#3

derjochenmeyer - March 8, 2008 - 14:32

eng.anas: to solve this problem i tried flat forum and advanced forum, and i found it so hard to deal with it.

i didnt try it myself, but the module page says that there is more than just enableing it. it just seems from what i've heard. but i tried the demo page and i really like advanced forum. is there a way to make this theme "advanced forum ready"?

#4

eng.anas - March 8, 2008 - 14:41

iam at work now and i'll spenda night working on advanced forum, i want you to notice that four seasons theme has its own forum node while others themes don't(that what i know), i really tried once with flat and another once with advanced and it wasn't work at all.
so now iam going to do more work to enforce one of them to be sauitable with four Seasons
thanx derjochenmeyer and thanx Michelle.
derjochenmeyer could give advanced forum a try :) and we will compare results
see you after 8 hours bye

#5

Michelle - March 8, 2008 - 14:46

You can use advforum with this theme. Just follow the install instructions. Since this is one of those themes that doesn't return $vars from all cases (*grumble*) I'm including the _phptemplate_variables change here:

<?php
function _phptemplate_variables($hook, $vars) {
  if (
module_exists('advanced_forum')) {
   
$vars = advanced_forum_addvars($hook, $vars);
  }

  if (
$hook == 'page') {

    if (
$secondary = menu_secondary_local_tasks()) {
     
$output = '<span class="clear"></span>';
     
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
     
$vars['tabs2'] = $output;
    }

  }
  return
vars;
}
?>

You might also want to comment out the innards of function phptemplate_comment_wrapper because this theme copies the buggy code from garland.

Note that this will get you the default advforum theme, not anything specially themed to match Four Seasons. It would be nice if the maintainer would put in css for advforum but that's his/her call.

Michelle

#6

derjochenmeyer - March 9, 2008 - 18:34

Hi Michelle, thanks :)

you forgot a "$" before vars in your code above. Here is what you have to copy to your template.php to make it work in fourseasons.

Make sure you remove the original functions first
- _phptemplate_variables()
- phptemplate_comment_wrapper()

<?php
function _phptemplate_variables($hook, $vars) {
  if (
module_exists('advanced_forum')) {
   
$vars = advanced_forum_addvars($hook, $vars);
  }

  if (
$hook == 'page') {

    if (
$secondary = menu_secondary_local_tasks()) {
     
$output = '<span class="clear"></span>';
     
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
     
$vars['tabs2'] = $output;
    }

  }
  return
$vars;
}

/**
* Allow themable wrapping of all comments.
*/
function phptemplate_comment_wrapper($content, $type = null) {
    return
'<div id="comments">'. $content . '</div>';
}
?>

@Michelle: I guess it makes no sense to integrate the "advforum" folder into fourseasons? It would be a mess with updates, right?

#7

derjochenmeyer - March 9, 2008 - 18:36
Status:active» postponed

I'll work on improving the formus or integrating advforum as soon as i have more time...

#8

derjochenmeyer - March 9, 2008 - 18:45
Title:forum theme» Theming the Comments in Forums

#9

Michelle - March 9, 2008 - 20:28

" I guess it makes no sense to integrate the "advforum" folder into fourseasons? It would be a mess with updates, right?"

That's what the Sky theme does. Unfortunately, Jacine was a very early adopter and does have a bit of a mess from the D6 backport right now. But things are settling down. I don't plan on any really radical changes to the files anymore. You can actually do quite a bit to change the look of the forums to fit a theme just in the CSS as well. So you might want to start with that. The advforum CSS comes after the forum module CSS and before the theme's CSS so if you put something in the theme, it will override what the module provides.

I think within the next couple of weeks the theme files should have stabalized to the point where theme maintainers can feel confident taking what's there, modifying it to fit their theme, and including the folder in the theme. Most of the work is done in the preprocess functions which are in the module code itself so the .tpl files will be changing very little.

Michelle

#10

derjochenmeyer - March 9, 2008 - 20:45

What i would have to do is make the changes in the template.php and add the advforum folder to the theme dir, right?

That would make it a one click installation for any new user.

PS: why is garland returning array()? What advantages/disadvantages has it to return $vars? if any...

#11

Michelle - March 9, 2008 - 21:09

If you put the changes in template.php, that right there is a big help since that is the most confusing part of installing advforum for most people. Since it checks if the advforum module is installed, it doesn't hurt anything if it's not.

Then, you can take it a step further and provide your own version of the advforum theme with your theme just by including the directory and your modified files. The module is currently hardwired to look for a directory named "advforum" but that will change, eventually, to allow for multiple forum themes. I've named all the .tpl files with advf-* so they won't interfere with other theme files when advforum isn't installed. This isn't a problem in 5.x because Drupal won't look in subdirectories unless you tell it to. But with 6.x it looks in subdirectories automatically.

I'm guessing garland returns array() because it doesn't have any code for any hook other than page so it basically is returning nothing for all other hooks. That's fine until you try and add code for the other hooks and your new variables aren't getting returned. So I have to try to explain to people who aren't programmers that they need to return $vars from all hooks. Which is not fun. :( Thankfully this problem is gone in 6.x since there's no more _phptemplate_variables to make my life miserable. :)

Michelle

 
 

Drupal is a registered trademark of Dries Buytaert.