Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

Is there is any way to limit signature length?

This discussion is related to the Signatures addon.

Is there is any way to limit signature length?

Best Answers

Answers

  • 422422 Developer MVP

    Surely you could using strlen

    eg.

    $string = substr($string,0,10).'...';
    

    422 Real Estate Australia , now open Check it out

    UnderDog
  • 422422 Developer MVP

    A quick snippet I found online which you could implement.

    <?php
    
    function cutAfter($string, $len = 30, $append = '...') {
            return (strlen($string) > $len) ? 
              substr($string, 0, $len - strlen($append)) . $append : 
              $string;
    }
    
    echo cutAfter('foo bar baz', 2)."\n";
    echo cutAfter('foo bar baz', 10)."\n";
    echo cutAfter('foo bar baz', 11)."\n";
    
    echo cutAfter('foo bar baz', 6, '!!!')."\n"; ?>

    Outputs:

    foo bar ba...

    foo bar...

    foo bar baz

    foo!!!

    422 Real Estate Australia , now open Check it out

    UnderDog
  • 422422 Developer MVP

    Or optionally: easiest method

    $string = (strlen($string) > 13) ? substr($string,0,10).'...' : $string;
    

    422 Real Estate Australia , now open Check it out

    UnderDog
  • thanks @422 Please can you tell me what file i should edit? I could not find $string = (strlen($string) > 13) ? substr($string,0,10).'...' : $string;

  • if you are using the signature plugin and just using straight text. this will cut the the sig length properly. With tags and images your results may vary.

    around line 260 in the signatures.class.plugin.php
    
    change - 
    
     $UserSig = $UserSignatures[$SourceUserID];
        if ($HideImages) {
    
    
    to this.  (replace the 10 with the number of chars you want).
    
     $UserSig = $UserSignatures[$SourceUserID];
       $UserSig =  substr($UserSig,0, 10); 
        if ($HideImages) {
    

    BTW - @fh111 is an expert on truncation now - he can probably give you some tips now.


    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    422UnderDog
  • But the easiest and probably the best way if you are concerned about the number of lines the signature takes up. just use css and multiply the lines you want by the font-size to se the height.

    for a one-line restriction - just change the signature.css in the design folder of the plugin and add a height parameter.

    .UserSignature {
       border-top: 1px solid #595959;
       padding: 2px 0px;
       font-size: 11px;
       margin-top: 10px;
       height: 14px;
    }
    

    factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!

    Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant

    UnderDog
Sign In or Register to comment.