Everyone knows that on some discussions comments can indent ludicriously. How can I limit it a depth of 2 replies only?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | comment.module.diff | 5.73 KB | pianomansam |
Everyone knows that on some discussions comments can indent ludicriously. How can I limit it a depth of 2 replies only?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | comment.module.diff | 5.73 KB | pianomansam |
Comments
Comment #1
ainigma32 commentedDo you want to make it impossible to add a comment after 2 replies or do you mean something else?
- Arie
Comment #2
Flying Drupalist commentedI want to make it impossible to add a comment after a depth of 2.
Comment
-comment
--comment
---comment NO WORK, auto defaults to->
--comment
Comment
Comment #3
ainigma32 commentedHmmm still not sure. So do you want to make it impossible for users to add a comment once the there are two comments or do you want to reset the indentation after two comments?
- Arie
Comment #4
Flying Drupalist commentedI don't want to do either, I want to make it so users can't do a level 3 indentation. When they use a reply that would normally result in a level 3 indentation, it ends up being a reply to the parent (and hence level 2).
Thanks for all your help.
Comment #5
ainigma32 commentedWell it's not really what you want but this module http://drupal.org/project/flatcomments does prevent indenting getting crazy (by eliminating all indentation).
Will that do?
- Arie
Comment #6
Flying Drupalist commentedThanks, I would like to still be able to use threading though.
Comment #7
ainigma32 commentedWell looking at this one more time I still think the easiest solution would be to use the flatcomments module.
I looked at the code and the only thing this module does is making all replies into replies to the node.
If you mean by threading that you want to keep the parent-child relation of the comments, wouldn't your explanation in #4 mess up the thread too?
You might consider hacking the flatcomments module to only force the reply to be to the node when it is a reply to a node that's already indented twice. but I don't if that can be accomplished easily.
- Arie
Comment #8
Flying Drupalist commentedWell it's enough for me to know that there's no already existing solution for it. I think some people are already working on modules for this.
Comment #9
Kane commentedHere what i've found:
In comment module you can find function comment_render in which you can find if else statements:
If we alter conditions like this:
where $max_thread_depth stores number which represents how deep thread could be. Now we can put $max_thread_depth somewhere in theme global settings or in settings of comment in current content type (where you chose flat, threaded order of comments etc). There will be small field which will store it's value in database and will use it for comments in chosen content type. If value = 0 then thread depth's unlimited.
When $max_thread_depth is reached comments will be rendered flat.
I'm not a programmer so i hope those who know more than i can implement this stuff in comments.
If you don't mind hacking core module you can make something like that:
This code will limit depth of thread up to 5 replies in a row, then comments will be flat rendered.
By the way, maybe there's a way to rewrite this function in template.php?
Comment #10
toemaz commentedOr use css to flat the comments:
where the number of .indented is where you wish to flat the indentation.
Comment #11
meecect commented#10 confirmed. Thats a great solution.
Comment #12
pianomansam commentedYes, I know, this is an old issue. But it's still incomplete. Solutions given in #9 and #10 seem to fix the issue on the surface. But as they description page on http://drupal.org/project/flatcomments mentions, a comment on a previous, non-top level comment will appear "underneath" it's parent issue, causing the comments to appear out of order.
There are two solutions to this dilemma. The first is to go the way of flatcomments.module and modify the way sub-comments are stored. This is a fine solution which wouldn't take much more than a custom hook_link_alter(). However, if you ever wanth to switch to a different display method, you can't because you are stuck.
The other solution would be to not modify the stored values, but instead to modify the display. This is quite difficult because the way comments are stored in the database. Comments only have parent comment ids stored, and a combined hierarchy column. In other words, to limit the amount of reply depth, this would have to be done on the PHP level, not SQL.
I've attached a patch with my attempt to do this. It appears to work in my environment but there is no guarantee it will work outside of it.
I'm also marking this as "won't fix) because Drupal 6.x is two versions behind.
Comment #13
zuernbernhard commentedHm why not just hide the "Reply" link on the deepest possible (desired) level (comment depth) ?
Comment #14
liam morlandDrupal core issue about limiting comment depth.