Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
563 views
in Plugins by
edited by

Just found out that the text-cutting dots "..." are not appearing when there is a space in the end of the cut string. Because then it is not 100 chars. So I suggest this tiny improvement:

From line 117:
    // answer snippet
    $answer['acontent'] = qa_substr( strip_tags($answer['acontent']), 0, 100 );
    if ( strlen($answer['acontent']) == 100 )
        $answer['acontent'] .= '...';


To:

    // answer snippet
    if ( strlen($answer['acontent']) > 100 ) {
        $answer['acontent'] = qa_substr( strip_tags($answer['acontent']), 0, 100 );
        $answer['acontent'] .= '...';
    }


 

Furthermore, if there are no best answers, $sel_count = $row['selected']; at line 97 is empty. To show 0 you can add:

$sel_count = $row['selected'];
if(empty($sel_count)) $sel_count = 0; // added
 

1 Answer

0 votes
by

A space character should be counted in the string length, it is not removed. I checked on my site and several snippets show a space on the end before the '...'

 
I think the problem may be that I only use strlen and not qa_strlen (which checks for multibyte/unicode characters). But I will change it to make it more robust. Thanks for the input.
by
you are welcome, glad to improve your code a bit.
...