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 commentings 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.
But the module using the button at the right, or
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).
Comments
Comments are closed. To get support, email .(JavaScript must be enabled to view this email address).


great module
Test comment reploy…
another response…
testing
wrong link to devotee.
fixed, thanks
No you did not :( LOL
It still points to http://devot-ee.com/add-ons/stand-alone-member-register/
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
yet another test reply
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.
I finally implemented this on my own site
You can see it in work in this thread
Just testing
Is there a way to display the total number of comments?
Sure. Use {total_comments}
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_id
SET exp_comments.parent_id = exp_weever.parent_id,
exp_comments.root_id = exp_weever.root_id,
exp_comments.level = exp_weever.level
Thanks for sharing, Mike!
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($result, MYSQL_ASSOC)) {
$arr[$row['comment_id']] = $row;
}
function crawl($c, $i) {
global $arr;
if($c['parent_id'] == 0) {
return array(
"root_id" => ($i == 0) ? 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($comment, crawl($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!
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?
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
Hi Yuri,
Do you have any updates on this?
Hi Ryan,
just released new version with {username} variable added
Yuri, you are absolutely the man. Thank you, this works like a charm!
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?
Ryan,
there are 2 notification checkboxes available within threaded comments form:
<input type="checkbox" name="notify_me" value="y" /><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)
Yuri,
You are awesome—I overlooked those in the docs. Thank you!
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!
Hi Ryan,
I’ll take some time to test this. Thanks for letting me know.
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?
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)
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.
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.