Display signatures once only per page

Started by wing, October 30, 2005, 10:26:45 AM

Previous topic - Next topic

wing

Hi, I thought I would share this small mod.  I noticed my board was getting cluttered by signatures if someone posts ten times in a topic you see their signature 10 times.

So I wrote a quick mod that displays each signature only once per page, the second page of the topic will have the sig again but I wasn't really too concerned abou that and don't think it's worth the effort. 

This was actually really easy to do.  In Display.template.php

find
//Show the member's signature?

Before this line add

// Show signature only once
               $IDAlreadyDisplayed = 0;
               if (!empty($MemberIDList)) {
                 if (in_array($message['member']['id'], $MemberIDList))
                    $IDAlreadyDisplayed = 1;
               }


Then change
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))
echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';


to the following:

if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && !$IDAlreadyDisplayed) {
                        echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';
                $MemberIDList[] = $message['member']['id'];
                } // endif I added the brackets


That is all enjoy!  ;D

snork13

#1
works great, thanks for sharing :)

in 1.1rc1 i had to search for

      if (!empty($message['member']['signature']) && empty($options['show_no_signatures']))
echo '
<hr width="100%" size="1" class="hrcolor" />
<div class="signature">', $message['member']['signature'], '</div>';
Mods
Please DO NOT PM me with requests for individual support, but post your questions and concerns in the appropriate section of the forum where other users can benefit from them as well. Thank you.
I have been super busy as of late. Working on updates to all my modifications for 2.0.1

dcmouser

proud member of donationcoder.com (forum)

c3vettes

 :) Sounds perfect. So where's this option located in the cp?
SMF 1.1.5, Subdreamer 2.4 Pro, Coppermine 1.4.10, Flash Chat 4.8.3
www.ncvettes.com
www.cheersdears.com
www.josephcwoodard.com

1MileCrash

it's not an "option"...hence all the code.
The only thing php can't do is tell you how much milk is left in the fridge.



c3vettes

Quote from: Tippmaster on November 08, 2005, 05:07:27 PM
it's not an "option"...hence all the code.

I can't find anything relating to signatures, aside from creating one.  Are the existing posts affected, or just the new ones after the code is modded? ???
SMF 1.1.5, Subdreamer 2.4 Pro, Coppermine 1.4.10, Flash Chat 4.8.3
www.ncvettes.com
www.cheersdears.com
www.josephcwoodard.com

JayBachatero

No there is no administration for this.  Its just a simple change that will do it automatically.  No way to turn it on off install uninstall.  All it does is that instead of displayin you sig everytime you make a reply to a topic it just displays it in your first post or fist page of the topic.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

c3vettes

SMF 1.1.5, Subdreamer 2.4 Pro, Coppermine 1.4.10, Flash Chat 4.8.3
www.ncvettes.com
www.cheersdears.com
www.josephcwoodard.com

wing

I was asked to change this a little so I did  :P

The text repeating isn't as much of a concern as images repeating, so I have edited my code to show the signatures more than once but the second time on it only shows the text and not the images.


// Show signature only once
               $IDAlreadyDisplayed = 0;
               if (!empty($MemberIDList)) {
                 if (in_array($message['member']['id'], $MemberIDList))
                    $IDAlreadyDisplayed = 1;
               }
                // Show the member's signature?
                if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && !$IDAlreadyDisplayed) {
                        echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';

                                                        $MemberIDList[] = $message['member']['id'];
                } elseif(!empty($message['member']['signature']) && $IDAlreadyDisplayed && empty($options['show_no_signatures'])) {
                                                        $Sig = $message['member']['signature'];
                                                        $tags_to_strip = Array("img");
                                                        foreach ($tags_to_strip as $tag) {
                                                           $Sig = preg_replace("/<\/?" . $tag . "(.|\s)*?>/","",$Sig);
                                                        }
                        echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $Sig, '</div>';


                }// endif I added the brackets

FBI

Its work on RC2. I am using SAFGrey theme.
Thank You :)

yeahimsteve

This is totally wonderful.  I too concur that it works very nicely with RC2.  Thank you again!   ;)

carlatf

Hi,
this is an AWESOME modification, it really cleans up the pages.

A single question, is there a way to modify it to display only one the member location, text, and age?
Is there a way to show only once the title if it's not changed by a user?

best,
Carla

wing

Sure anything is "possible".  The thing is you don't want to do too many of these "enhancements" as it will begin to slow down your load times on the pages, you'll also start to suck up memory if you start sorting and checking everything upon display.

loldaolda

Should be built in feature ;)
*hint*hint*

carlatf

Quote from: wing on March 21, 2006, 11:47:01 AM
Sure anything is "possible".  The thing is you don't want to do too many of these "enhancements" as it will begin to slow down your load times on the pages, you'll also start to suck up memory if you start sorting and checking everything upon display.
Do you have any idea of how much?
I'd like to delete the avatars and all the user info, if the user posted more than once too.
best,
Carla

wing

No idea, but if you know a little php and html you can copy my code and add the avatar stuff as well.

spiketowriss


ivo2296

Quote from: wing on January 26, 2006, 07:07:35 PM
I was asked to change this a little so I did  :P

The text repeating isn't as much of a concern as images repeating, so I have edited my code to show the signatures more than once but the second time on it only shows the text and not the images.


// Show signature only once
               $IDAlreadyDisplayed = 0;
               if (!empty($MemberIDList)) {
                 if (in_array($message['member']['id'], $MemberIDList))
                    $IDAlreadyDisplayed = 1;
               }
                // Show the member's signature?
                if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && !$IDAlreadyDisplayed) {
                        echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $message['member']['signature'], '</div>';

                                                        $MemberIDList[] = $message['member']['id'];
                } elseif(!empty($message['member']['signature']) && $IDAlreadyDisplayed && empty($options['show_no_signatures'])) {
                                                        $Sig = $message['member']['signature'];
                                                        $tags_to_strip = Array("img");
                                                        foreach ($tags_to_strip as $tag) {
                                                           $Sig = preg_replace("/<\/?" . $tag . "(.|\s)*?>/","",$Sig);
                                                        }
                        echo '
                                                        <hr width="100%" size="1" class="hrcolor" />
                                                        <div style="overflow: auto; width: 100%; padding-bottom: 3px;" class="signature">', $Sig, '</div>';


                }// endif I added the brackets


Works perfect on smf 1.0.7

Thanks a lot!

MothMan

If I understand the code correctly, it sets the signature to only display in the first post by that member, on that page.

Could it be modified to only show the signature on the LAST post by that member, on that page?

wing

Ouch that would be tough.....  ???  I don't think so...

Advertisement: