Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Is there is any way to limit signature length?

ruwan23ruwan23 New
edited July 2012 in Vanilla 2.0 - 2.8

Is there is any way to limit signature length?

Best Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    There isn't a way to limit signature length, no.

  • 422422 Developer MVP
    Answer ✓

    You need to identify the var that controls signatures, i dont know it. Im on ipad having a smoko outside lol. @underdog or @peregrine or @x00 can help, they are geniususeseses

    There was an error rendering this rich post.

Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    There isn't a way to limit signature length, no.

  • :-( :-( I thanks @Todd

  • 422422 Developer MVP
    edited July 2012

    Surely you could using strlen

    eg.

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

    There was an error rendering this rich post.

  • 422422 Developer MVP
    edited July 2012

    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!!!

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Or optionally: easiest method

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

    There was an error rendering this rich post.

  • 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;

  • 422422 Developer MVP
    Answer ✓

    You need to identify the var that controls signatures, i dont know it. Im on ipad having a smoko outside lol. @underdog or @peregrine or @x00 can help, they are geniususeseses

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited July 2012

    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.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited July 2012

    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;
    }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.