I needed to apply CSS styling to the signatures on my forum, so I've modified my module to allow this (and fixed a typo).

I just had to port my changes to the latest dev release of the module, so I'm wondering if we can't just get something like this added to the module itself so that others can benefit from it and I won't have to keep porting my small changes? :)

The first part makes sure no unnecessary code is added if there isn't any actual signature to begin with. For some reason some of my empty sigs would still get themed anyway, so this fixed that.

Second part adds the styleable code. Third part fixes the typo.

As they say "It works for me."

diff -ur signature_forum/signature_forum.module signature_forum-phreadom/signature_forum.module
--- signature_forum/signature_forum.module      2012-07-05 15:39:53.000000000 -0400
+++ signature_forum-phreadom/signature_forum.module     2012-07-06 08:14:03.303936600 -0400
@@ -593,12 +593,14 @@
     // Add signature_forum to the render array.
     $user = user_load($node->uid);

-    $node->content['signature_forum'] = array(
-      '#signature' => check_markup($user->signature, $user->signature_format, '', TRUE),
-      '#theme' => 'user_signature',
-      '#pre_render' => array('signature_forum_pre_render_user_signature'),
-      '#user' => $user,
-    );
+    if (isset($user->signature) && drupal_strlen($user->signature) >= 1) {
+      $node->content['signature_forum'] = array(
+        '#signature' => check_markup($user->signature, $user->signature_format, '', TRUE),
+        '#theme' => 'user_signature',
+        '#pre_render' => array('signature_forum_pre_render_user_signature'),
+        '#user' => $user,
+      );
+    }

     $body = field_get_items('node', $node, 'body', $langcode);
     if ($body) {
@@ -629,7 +631,7 @@
     // Add signature_forum to the render array.
     if (!isset($comment->signature_forum_status) || $comment->signature_forum_status) {
       $comment->content['signature_forum'] = array(
-        '#signature' => check_markup($comment->signature, $comment->signature_format, '', TRUE),
+        '#signature' => '<div class="sff-signature">'.check_markup($comment->signature, $comment->signature_format, '', TRUE).'</div>',
         '#theme' => 'user_signature',
         '#pre_render' => array('signature_forum_pre_render_user_signature'),
         '#user' => user_load($comment->uid),
@@ -706,7 +708,7 @@

           case SIGNATURE_FORUM_ADDITIONAL_FILTER_FORMAT:
             $element['#signature'] = check_markup($element['#signature'], variable_get('signature_forum_short_content_format'), '', TRUE);
-            breaK;
+            break;
         }
       }
     }

Comments

Skin’s picture

I tried this patch, but I can not see the class = "SFF-signature " in the first post, all the following posts have this class.

Skin’s picture

I tried this patch, but I can not see the class = "SFF-signature " in the first post, all the following posts have this class.

joelrichard’s picture

FWIW, The code does NOT add the <div class="sff-signature"> to the original post of the topic. It DOES add it to all of the subsequent comments. This is what Skin was referring to. The fix is to apply the div to line 598:

        '#signature' => '<div class="sff-signature">'.check_markup($user->signature, $user->signature_format, '', TRUE).'</div>',
joelrichard’s picture

Oops, there is a better way to do this. The Signatures for Forum module relies on the core user theme for printing signatures. So put this into your Theme's template.php file and override whatever you need to change. :)

function MYTHEME_user_signature($variables) {
  $signature = $variables['signature'];
  $output = '';

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

  return $output;
}
Liam McDermott’s picture

Status: Needs review » Closed (works as designed)

@joelrichard, thanks very much for updating this issue, your reply is exactly what I would have said. :)

phreadom’s picture

Thanks guys. That is a much better solution. Works perfectly for me.