I've spent hours searching here and on the web for the correct format to put the $signature variable in my nodes for Drupal 6.1. My understanding is that I must place something like the following in my template.php file:

function phptemplate_preprocess_node(&$variables) {
  $variables['signature'] = [function or variable]; 
}

but I don't know the correct function or variable to put in there. Is it some use of theme_user_signature or some part of $user?

Thanks.

Comments

dvessel’s picture

function phptemplate_preprocess_node(&$variables) {
  $variables['signature'] = theme('user_signature', $variables['user']->signature);
}

joon park
–the devil in the details–

michelle’s picture

I'm looking at http://drupal.org/node/132442#signature and it looks like the variable already exists.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

dvessel’s picture

I believe that's only for comments. Nodes do not output sigs by default. I could be wrong, haven't looked. :)

joon park
–the devil in the details–

michelle’s picture

All that work to fix signatures in 6.x and it didn't get put on nodes? LOL!

I guess the signature_forum module is still needed in 6.x. I'll have to have a look at helping Liam port that.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

dvessel’s picture

Yeah, I know. It should have gone in there. We do have forum node types and all..

joon park
www.dvessel.com

brianmercer’s picture

OK, that doesn't work. That inserts the signature of the currently logged in user. It must be some part of the $node variable?

Yeah. $signature is only in comments, by default.

dvessel’s picture

Right, that's the wrong object.. use this instead. You must load based on the uid (user id) of the author of the node.

function phptemplate_preprocess_node(&$variables) {
  $node_user = user_load($variables['node']->uid);
  $variables['signature'] = theme('user_signature', $node_user->signature);
}

joon park
www.dvessel.com

brianmercer’s picture

That does work to insert the signature. However it does not apply filters to the signature. I'm looking at a forum node created by a user and then the same user posted a comment. The signature uses BBCode. The comment signature is correct, but the node signature does not apply the BBCode filter and comes out with the bare codes.

Sorry, joon. I thought this would be an easy one. I appreciate your effort.

dvessel’s picture

One thing you can do is to place a debug_backtrace within the overridden function for the signature. http://api.drupal.org/api/function/theme_user_signature/6

function phptemplate_user_signature($signature) {
// Looksie in here while viewing a comment.
print var_dump(debug_backtrace());
exit;

  $output = '';
  if ($signature) {
    $output .= '<div class="clear">';
    $output .= '<div>—</div>';
    $output .= $signature;
    $output .= '</div>';
  }

  return $output;
}

From there, look at the trace, and follow it to push your node sig through the same steps.

Make sure you remove the code you placed for the node so it doesn't interfere with your debugging.

Good luck.

joon park
www.dvessel.com

brianmercer’s picture

It's definitely formatting them differently. Oddly it's adding a

-

as a separator above the node signatures now, but not above the comment signature, as well as applying filters differently.

Thanks to you I have a temporary solution to show signatures. I will start tracking down the cause of the different formatting and post back here if I find a solution. Thanks again.

brianmercer’s picture

OK, apparently comment signatures don't use theme_user_signature because that's the function that's causing the separator.

function theme_user_signature($signature) {
  $output = '';
  if ($signature) {
    $output .= '<div class="clear">';
    $output .= '<div>—</div>';
    $output .= $signature;
    $output .= '</div>';
  }

  return $output;
}

The quest for perfect signatures continues...

michelle’s picture

So on comments, it's correctly processing the bbcode? I'm looking at the text area for the signature and it doesn't have any input formats listed, which implies it only does plain text. I don't have bbcode installed to check.

Thanks for this thread, by the way, I didn't even notice the signature variable wasn't on nodes when I committed my change to advanced forum earlier. I'm looking into this to see how hard it would be to add it or if I should focus on porting signature_forum to D6.

[Edit] Nevermind. Just found the code. Looks like it runs it through the input format of the comment.

$comment->signature = check_markup($comment->signature, $comment->format);

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

michelle’s picture

Ok, this is the code I just added to advforum:

    if (variable_get('user_signatures', 0) {
      $author = user_load(array('uid' => $vars['node']->uid));
      $vars['signature'] = check_markup($author->signature, $vars['node']->format);
    }

Seems to work ok from my limited testing.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

brianmercer’s picture

Thank you very much Joon and Michelle.

OK, I have the following in my template.php theme file:

function phptemplate_preprocess_node(&$variables) {
  $author = user_load(array('uid' => $variables['node']->uid));
  $variables['signature'] = check_markup($author->signature, $variables['node']->format);
}

and the following in my node.tpl.php (or node-forum.tpl.php) file:

  <?php if ($page && !empty($signature)): ?>  
      <div class="user-signature clear-block">
        <?php print $signature ?>
      </div>
   <?php endif; ?>

and it's showing exactly what I want, which is filtered signatures on nodes and not on node lists.

However, the check for an empty signature isn't working. If a person has no signature, I still get

<div class="user-signature clear-block">
<p/>
</div>

Visually not a problem atm, but can anyone suggest a way to improve it to not show an empty div?

michelle’s picture

Your div isn't empty. It has a <p/> in it, which is not in your markup, and therefore must be in the signature variable. So you need to find out what's putting that in there. Probably your input filters.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

brianmercer’s picture

Right on. Thanks again for the help, Michelle.

snsace’s picture

So do these theme edits take care of the Signatures in Forum nodes, or is the
Signature for forums module still needed. I am currently using 5.x w/signatures module.

I see the Signatures For Forums module is in alpha release for 6.x
I am not currently using Adv Forum.