WordPress.org

Ready to get started?Download WordPress

Forums

needed: Word Wrap for Comments (12 posts)

  1. garvinmusic
    Member
    Posted 9 years ago #

    i have built my site, using wordpress, and have been able to figure out every little problem that my friend and i could think of. you know, in the process of trying to build a flawless site that can't be corrupted by jerks :)
    well, my friend corrupted it. he left a comment to one of the stories, and it was just "11111" times about 50. basically a total of 100+ "1"s in one line. well, instead of wrapping, or breaking the word, it just stretches my page:
    http://www.en4mation.com/wordpress/index.php?p=3
    now, i've tried to use some basic HTML to do it, then i tried using CSS. neither worked. this is very frustrating and i can't figure it out. has there been a hack to fix this, or does anyone know how exactly to fix this problem so we don't run into it once the page goes live?

  2. Joshua Sigar
    Member
    Posted 9 years ago #

    With the following, if there's a long single word, it'' be cut off (not wrapped)
    ol#commentlist {
    overflow: hidden;
    width: 400px;
    }

  3. garvinmusic
    Member
    Posted 9 years ago #

    well, i don't think i want the post to just disapear, per ce. i'd like it to wrap, just because if someone wants to provide a URL, i'd like that URL to show in its entirety, just not to stretch the page. this seems like it would cut the comment, and that word, so that it wouldn't be the link in its entirety.

  4. Joshua Sigar
    Member
    Posted 9 years ago #

    As long as the url is still clickable, you don't need to see the whole thing to go to the site

  5. garvinmusic
    Member
    Posted 9 years ago #

    "There's no way to wrap it other than to run a php function to split long words/strings of characters within a comment." This is what I am looking for Kafkaesqui. I haven't been able to find this hack in WordPress yet. Would anyone be interested in helping me impliment such a code on my site? The scrolling bar idea just doesn't seem...attractive right now.

  6. m8rk
    Member
    Posted 9 years ago #

    I asked the same thing of the author of the recent_comment plugin I use - Krischen - the same day he provided a revised version with code added to split long text strings. Find the plugin here: http://blog.jodies.de/archiv/2004/11/13/recent-comments/

  7. m8rk
    Member
    Posted 9 years ago #

    oops! posted too soon - I meant to add - is this a way to solve the problem - the code adds a break in a long text string to enable the text to wrap correctly - proble with this solution is that long URL's will be broken.

  8. m8rk
    Member
    Posted 9 years ago #

    OK I suck at this :( ... here's Krischans explanation [I sure he wouldn't mind me sharing :)] :
    $comment_short = preg_replace("/([^\s]{30})/","$1 ",$comment_short);
    "Replace every bunch of 30 or more characters that are not equal whitespace with itself and add blank after it". The 30 should be configurable, but php seems to not evualute a variable at that place.

  9. ryoken
    Member
    Posted 9 years ago #

    hah.. that plugin was released on my b-day ^_^.

    works like a charm for me - set at 90 chars with a space as my break character.

  10. NuclearMoose
    Member
    Posted 9 years ago #

    'Flagged for Codex'

  11. blueorder
    Member
    Posted 9 years ago #

    Works like a champ...

  12. evilwilly
    Member
    Posted 9 years ago #

    I had the same problem and cobbled together this hack from two or three other similar functions I saw on the net:

    function word_wrap($texte,$lng_max) {
    // Script
    $esp=explode(" ",$texte);
    $i=0;
    $carac_dep=0;
    $tmp_txt="";
    // sur tout la longeur du texte
    while ($i<=count($esp)) {
    $lng_mot=strlen($esp[$i]);
    // si le mot est trop gd
    if ($lng_mot>$lng_max) {
    // on decoupe
    $nb_f=($lng_mot/$lng_max)+1;
    $mot="";
    for ($j=0;$j<=$nb_f;$j++) {
    $mot.=substr($esp[$i],($j*$lng_max),$lng_max)."<br />";
    }
    $esp[$i]=$mot;
    }
    $tmp_txt.=$esp[$i]." ";
    $i++;
    }
    return $tmp_txt;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.