WordPress.org

Forums

[resolved] the --more-- with comments (5 posts)

  1. deuced
    Member
    Posted 7 years ago #

    hello

    i have my WP installation working great but i m also trying to find a solution to an issue with comments in each post.

    since my blog gets long comments (many of them are really long) i wanted to find a solution to add in someway the "read more" funcionality.

    i.e. i would be happy if there was a way to display all comments in every post BUT only the first 50 or 100 characters (or words) and have a button or a text link and if someone wanted to "expand" a specific comment could press it.

    i searched in many comment plugin but couldn't find something useful so i thought that i might ask here if there's a way to use the --more-- function in comments to solve my problem.

    i would appreciate any ideas on how to experiment or if there's a plugin that i didnt noticed.

  2. moshu
    Member
    Posted 7 years ago #

  3. deuced
    Member
    Posted 7 years ago #

    Doesn't solve my problem but it's a lot better than nothing and a place to start.

    Thank you moshu for the hint.

  4. deuced
    Member
    Posted 7 years ago #

    hello

    i tried to search for a plugin that could do my job done but couldnt find any

    the most helpful one was the ShowHideComments of José Lopes but it does hides the whole block of comments.

    So i thought that i could search a bit and see how this plugin could suit my needs.
    I m not a programmer and know nothing of javascript and only a bit of PHP that why i want, if anyone is interested, to test it and see the code cause i m not sure if i m on the right path.

    what i ve done is made a plugin named collapsiblecomments which shows the excerpt of comments and by demand expand the comments you want to read inline one by one

    You can download the plugin from my blog from this link and here is the code if anyone could suggest something better:

    if(function_exists('load_plugin_textdomain'))
            load_plugin_textdomain('collapsible-comments','wp-content/plugins/collapsible-comments');
    
    /* START FUNCTION */
     function collapsiblecomments () {
    
    /* COMMENT TEASER */
    		echo "<div id=\"id\" align=\"left\">";
    		echo "<a href=\"#comment-", comment_ID(), "\"> </a></div><font color=\"#808080\">Comment Excerpt:</font>", comment_excerpt();
    /* COMMENT TEASER */	  
    
    /* And a bit of CSS around */
        echo "<style type=\"text/css\">";
        echo ".text{display: none;}";
    /*    echo "#text{display: block;}; */
        echo "</style>";
    /* End of CSS block */
    
    /* And there is where the Javascript Starts */
        echo "<script type=\"text/javascript\">";
    /*
    Global "swap" holder
    Use value, null, if no layer initially visible
    */
    
        echo "
    
    var currlayerid = \"id\";
    
    function togLayer(id)
    {
    if(currlayerid) setDisplay(currlayerid, \"none\");
    if(id)setDisplay(id, \"block\");
    currlayerid = id;
    }
    
    function setDisplay(id,value)
    {
    var elm = document.getElementById(id);
    elm.style.display = value;
    }
    </script>
    
    ";
    /* And there is where the Javascript ends */
    
    /* step 1. Open a table for the FULL Comment */
        echo "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"6\" border=\"1\" bordercolor=\"#4e5706\"><tr><td>";
    
    /* And the code for toggle the comments starts here */
        echo "<a href=\"#\" onclick=\"togLayer('", comment_ID(), "');return false;\">Read the FULL comment</a>
    <br>";
    /* step 2. Show the FULL Comment (if u want) */
        echo "<div id=\"", comment_ID(), "\" class=\"text\"><font color=\"#CC000\">FULL:</font>", comment_text(), "</div>";
    /* Now close the FULL Comment */
        echo "<a href=\"#\" onclick=\"togLayer(null)\">Close Comment</a>";
    /* And the code for toggle the comments ends here */
    
    /* Step 3. Close the FULL comment table now */
        echo "</td></tr></table></p>";
    
    	}
    /* END FUNCTION */
  5. deuced
    Member
    Posted 7 years ago #

    I fix a bit of the code and finally create the plugin i needed. More info in it's page here. So this topic is marked as resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags