Skip to content

Threaded comments module

16 Jan 2011

Threaded comments module

This add-on enables nested commenting (comment on comment, reply to comment) for ExpressionEngine 2.x.

You can have unlimited depth of comment nesting.

Threaded comments module is using same database table that first-party comment module does will respect all commenting settings you have. It contains all extension hooks that comments module does, so all of your extensions will work.

All variables available with exp:comment:entries are available with exp:threaded_comments:display as well.

You can use different html for different levels of comments. Commenters are able to subscribe to notifications only for selected thread.

Buy the module using the button at the right, or get it from Devot:ee

See usage details in the docs

If you have feature request or bug reports, feel free to post them here.

For support, please email .(JavaScript must be enabled to view this email address).

Changelog RSS

  • v. 2.0 — 2011-01-16 06:13
    • Initial release
  • v. 2.0.7 — 2011-03-21 05:18
    • Bug fixes
  • v. 2.0.8 — 2011-03-23 05:18
    • Fixed nesting bug
  • v. 2.0.9 — 2011-03-29 11:18
    • Bug fixes
  • v. 2.1 — 2011-04-27 08:20
    • Alternative nesting syntax
  • v. 2.1.1 — 2011-05-04 20:08
    • Thread closing bug fix for alternative syntax
  • v. 2.1.2 — 2011-06-07 11:02
    • Bug fixes
    • Added variable
  • v. 2.1.3 — 2011-07-14 10:38
    • 0 fixes
  • v. 2.2.0 — 2011-07-31 16:36
    • Fixes for email notifications
  • v. 2.2.1 — 2011-08-03 20:58
    • Pagination fix
  • v. 2.3.1 — 2011-10-27 15:49
    • Bug fix
  • v. 2.3.2 — 2011-11-11 16:40
    • Cache-related bug fix
  • v. 2.3.4 — 2011-11-20 17:07
    • Minor fix
  • v. 2.3.6 — 2012-01-10 17:37
    • Bug fixes
  • v. 2.3.7 — 2012-02-11 11:48
    • Minor bug fix
  • v. 2.3.8 — 2012-03-03 13:47
    • Bug fix
  • v. 2.4.0 — 2012-08-29 09:28
    • entry_status parameter
    • member_group_id variable
  • v. 2.4.1 — 2012-10-09 11:11
    • Notification minor fixes
  • v. 2.4.2 — 2013-01-08 14:13
    • PHP 5.4 compatibility fix
  • v. 2.4.3 — 2013-01-22 20:02
    • EE 2.5.4 compatibility fix
  • v. 2.4.4 — 2013-05-09 16:31
    • EE 2.6 compatibility fixes
  • v. 2.4.5 — 2013-05-14 08:39
    • Bug fix
  • v. 2.4.6 — 2013-06-18 08:16
    • Compatibility related bug fix
  • v. 2.4.7 — 2013-09-24 12:40
    • fix for {comment_url} variable in notification emails
  • v. 2.4.8 — 2014-04-03 20:12
    • Pagination fix

Licensing & support terms

Comments

  1. khalifa
    khalifa 20 Jan 2011

    great module

    • Deerjohn
      Deerjohn 24 Apr 2011

      great module

      Test comment reploy…

      • Deeralex
        Deeralex 24 Apr 2011

        great module


        Test comment reploy…

        another response…

        • Ryan
          Ryan 16 Jun 2011

          testing

      • Test
        Test 07 Jul 2011

        great module


        Test comment reploy…

  2. lebisol
    lebisol 28 Jan 2011

    wrong link to devotee.

  3. Araceli Lapine
    Araceli Lapine 08 Mar 2011

    a acute pal once told me almost composting. Loved it while i tried saving the environment, also develop some movables wheatgrass and bought my own <a >wheatgrass juicer</a> here. Never looked back since.

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 08 Apr 2011

      a acute pal once told me almost composting. Loved it while i tried saving the environment, also develop some movables wheatgrass and bought my own <a >wheatgrass juicer</a> here. Never looked back since.

      a test reply

      • Visitor
        Visitor 08 Apr 2011

        a acute pal once told me almost composting. Loved it while i tried saving the environment, also develop some movables wheatgrass and bought my own <a >wheatgrass juicer</a> here. Never looked back since.

        a test reply

        a test reply again

      • Yuri Salimovskiy's avatar
        Yuri Salimovskiy 04 May 2011

        yet another test reply

  4. John
    John 08 Apr 2011

    Anyone have a link to a demo or a site using this add-on? I’m interested, but would like to see it in action before making a purchase.

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 08 Apr 2011

      I finally implemented this on my own site smile
      You can see it in work in this thread

  5. Matt Guevara
    Matt Guevara 14 Apr 2011

    Just testing

  6. kinoli
    kinoli 26 May 2011

    Is there a way to display the total number of comments?

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 27 May 2011

      Is there a way to display the total number of comments?

      Sure. Use {total_comments}

  7. Mike Marcacci
    Mike Marcacci 28 May 2011

    Great module—Just got it working, and I’m pleased so far! Quick note for anybody upgrading from EE1 who has been using Weever for comment threading: once you install “Threaded Comments,” you can migrate all your old threading with SQL:

    UPDATE exp_comments
    INNER JOIN exp_weever
     ON exp_comments
    .comment_id exp_weever.comment_id
    SET exp_comments
    .parent_id exp_weever.parent_id,
     
    exp_comments.root_id exp_weever.root_id,
     
    exp_comments.level exp_weever.level 
    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 28 May 2011

      Thanks for sharing, Mike!

    • Mike Marcacci
      Mike Marcacci 06 Jun 2011

      Great module—Just got it working, and I’m pleased so far! Quick note for anybody upgrading from EE1 who has been using Weever for comment threading: once you install “Threaded Comments,” you can migrate all your old threading with SQL:
      UPDATE exp_commentsINNER JOIN exp_weever ON exp_comments.comment_id = exp_weever.comment_idSET exp_comments.parent_id = exp_weever.parent_id, exp_comments.root_id = exp_weever.root_id, exp_comments.level = exp_weever.level 

      Turns out Weever and Nested Comments treat the columns a little differently, and after executing the above SQL, I noticed some problems getting the styling to work. You’ll need to recalculate the level and root_id from the parent_id field. I got it to work using a PHP script:

      <pre>
      <?php
      mysql_connect
      ("localhost""root""") or
          die(
      "Could not connect: " mysql_error());
      mysql_select_db("DATABASE_NAME");

      // Copy the parent_id from the weever table.
      $migrate mysql_query("UPDATE exp_comments INNER JOIN exp_weever ON exp_comments.comment_id = exp_weever.comment_id SET exp_comments.parent_id = exp_weever.parent_id");
      mysql_free_result($migrate);

      // Select all the relevant comment data from the database
      $result mysql_query("SELECT `comment_id`, `parent_id`, `root_id`, `level` FROM exp_comments ORDER BY `parent_id` DESC");

      $arr = array();

      $sql_root_id "";
      $sql_level "";

      // List all the comments by comment_id
      while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
          $arr[$row[
      'comment_id']] $row;
      }

      function crawl($c$i{
        
      global $arr;
        
        if(
      $c['parent_id'== 0{
          
      return array(
            
      "root_id" => ($i == 0) ? $c['comment_id']// Root comments have root_id=0
            
      "level" => $i
          
      );
        
      elseif(isset($arr[$c['parent_id']])) {
          
      return crawl($arr[$c['parent_id']]$i+1); // Go deeper
        
      else {
          
      return array("error"=>1); // If the parent was removed from the database (don't ever do this)
        
      }
      }

      // Calculate root_id and level for each comment
      foreach($arr as $id => $comment){
        $arr[$id] 
      array_merge($commentcrawl($comment,0)); // Crawl up the parent tree, and update $arr
        
      $sql_root_id .= "WHEN $id THEN ".$arr[$id]['root_id']."\n";
        
      $sql_level .= "WHEN $id THEN ".$arr[$id]['level']."\n";
      }


      // Concat the SQL
      $sql "
      UPDATE exp_comments
      SET level = CASE comment_id
      $sql_level
      END, root_id = CASE comment_id
      $sql_root_id
      END"
      ;

      #print_r($arr);   // Show the updated array
      #echo $sql;       // Show the SQL

      mysql_free_result($result);

      // Update the database with recalculated values
      $update mysql_query($sql);
      mysql_free_result($update);

      ?>
      </pre

      It seems to be working perfectly now… hope it helps someone!

  8. Ryan
    Ryan 01 Jun 2011

    Hey Yuri,

    Great work. I think there is a bug—the {username} variable is not parsed properly; it always returns the logged-in user’s username, rather than the author’s username. I tested the regular comments loop and it works as expected; would you mind checking into this?

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 01 Jun 2011

      Hey Ryan,
      I’m not sure this is a bug, as logged out comment authors do not have username. However I’ll add it in next release!

      • Ryan
        Ryan 01 Jun 2011

        Hey Ryan,
        I’m not sure this is a bug, as logged out comment authors do not have username. However I’ll add it in next release!

        Hey Yuri, thanks for the quick response. If you check the native EE comment functionality you’ll see that it pulls in the username for all comment authors, whereas yours only pulls the currently logged in user. It should pull the username for each comment author, regardless of whether they are signed in, right?

        Just thought you should know—if I’ve got things mixed up, let me know smile

      • Ryan
        Ryan 06 Jun 2011

        Hi Yuri,

        Do you have any updates on this?

        • Yuri Salimovskiy's avatar
          Yuri Salimovskiy 07 Jun 2011

          Hi Ryan,
          just released new version with {username} variable added

          • Ryan
            Ryan 11 Jun 2011

            Hi Ryan,
            just released new version with {username} variable added

            Yuri, you are absolutely the man. Thank you, this works like a charm!

  9. Ryan
    Ryan 14 Jun 2011

    Hi Yuri,

    Question on comment notifications: if I sign up to get notified of follow up comments, it only lets me know if someone responds to my comment, but not if someone leaves a general comment. Is this default EE behavior? Ideally I would get notified if anyone posted a comment, not just a threaded reply to my comment. Does that make sense?

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 15 Jun 2011

      Ryan,
      there are 2 notification checkboxes available within threaded comments form:

      <input type="checkbox" name="notify_me" value="y" /> 
      and
      <input type="checkbox" name="notify_thread" value="y" /> 

      The first one is used to notify about new comments in the thread, while the second one will make notification go if any comment to the entry has been submitted (and so acts just like in ‘native’ EE comments form)

      • Ryan
        Ryan 16 Jun 2011

        Yuri,

        You are awesome—I overlooked those in the docs. Thank you!

        Ryan,
        there are 2 notification checkboxes available within threaded comments form:
        <input type=“checkbox” name=“notify_me” value=“y” /> 

        and
        <input type=“checkbox” name=“notify_thread” value=“y” /> 


        The first one is used to notify about new comments in the thread, while the second one will make notification go if any comment to the entry has been submitted (and so acts just like in ‘native’ EE comments form)

      • Ryan
        Ryan 14 Jul 2011

        Hi Yuri,

        Just an update—I may just not understand the difference between the two notification options, but I don’t think the comment notifications are getting sent as expected. I am currently showing users the following:

        <label><input type=“checkbox” name=“notify_me” value=“y” checked=“checked” /> Notify me of future comments?</label>

        I’ve tested general EE comments, and notifications for those work all the time. If I leave a comment (as super admin), I am notified of responses. When I respond to another user’s comment, they are notified, and so on. With threaded comments, I am always notified of a reply to my comment, but other users (non super admins) are never notified.

        FYI, after speaking with EE support about this, they recommended going into a user’s account settings under “Email settings” and disabling “Enable smart notification,” which I did. I am not sure if this needs to be enabled for threaded comments to work.

        Any insight you can provide would be great. Thanks!

        • Yuri Salimovskiy's avatar
          Yuri Salimovskiy 14 Jul 2011

          Hi Ryan,
          I’ll take some time to test this. Thanks for letting me know.

  10. Philip
    Philip 13 Jul 2011

    Hi Yuri,
    Great module, i’m having a few problems at the moment though.

    Firstly {total_comments} seems to only give the total number of root comments and does not include nested comments, am I doing something wrong?

    Seconday, I’d like to style the comments from the entry author differently to ‘guest’ comments. Within the loop I have this for example: {if entry_author_id == author_id}author{/if} but this does not seem to be working correctly, any idea why?

    • Yuri Salimovskiy's avatar
      Yuri Salimovskiy 14 Jul 2011

      Hi Philip,
      the {total_comments} variable has been fixed - thanks for letting me know! I also added {total_threads} variable (which has total number of root comments now).

      As of {if entry_author_id == author_id} author{/if} - I just checked and it works. You may try enclosing variables in quotes ({if '{entry_author_id}’ == ‘{author_id}’} . If you’ll still not be able ti make it work - email me the full code you’re using to .(JavaScript must be enabled to view this email address)

      • Philip
        Philip 14 Jul 2011

        Hi Yuri,
        Thanks for that, i’ll check it out.
        I am also trying to display certain code only if the comment was left by a member of the site. For example on our new site I have a url for each person in our team (/people/philip). Now if I login and leave a comment on a post I want my name to link to my page on the site. If a general user leaves a comment I want either no link or a link to their external website. A great example of that is here: http://www.zurb.com/article/727/six-tips-for-designing-without-pixels#comments Any idea how to achieve this? Is there a way to find out if the user leaving a comment belongs to a member group or not? i.e If comment was left by a Super Admin do X otherwise ....

        Thanks.

        • Yuri Salimovskiy's avatar
          Yuri Salimovskiy 14 Jul 2011

          Well, you have all standard member profile fields available - {group_id}, {url}, {location} etc. If you need custom fields data, you are able to fetch member’s detailed profile as you have {member_id} also.

        • test
          test 19 Aug 2011

          Hi Yuri,
          Thanks for that, i’ll check it out.
          I am also trying to display certain code only if the comment was left by a member of the site. For example on our new site I have a url for each person in our team (/people/philip). Now if I login and leave a comment on a post I want my name to link to my page on the site. If a general user leaves a comment I want either no link or a link to their external website. A great example of that is here: http://www.zurb.com/article/727/six-tips-for-designing-without-pixels#comments Any idea how to achieve this? Is there a way to find out if the user leaving a comment belongs to a member group or not? i.e If comment was left by a Super Admin do X otherwise ....

          Thanks.

About

    Hello, my name is Yuri and I specialize in creating custom add-ons (plugins, modules, extensions) for ExpressionEngine CMS.
    You can reach me anytime by emailing .(JavaScript must be enabled to view this email address)