mmmag: A cotton cloud with drop shaped beads dangling below. (Default)
mmmag ([personal profile] mmmag) wrote in [community profile] style_system2009-09-11 07:34 pm

Stop comment indenting after a certain depth

This is a theme layer modification that stops comment indenting after reaching a certain comment depth. You can also customize how much each comment will indent from its parent comment.

function EntryPage::print_comments (Comment[] cs) {
#This is where you set the max comment depth that you want.
#After this comments will have the same depth as the parent comment.
var int no_indent_depth = 16;

#This is where you set how much each comment will indent in pixels.
#No need to add any units. Just the number.
var int no_indent_pixels = 16;

if (size $cs == 0) { return; }
foreach var Comment c ($cs) {
var string parity = $c.depth % 2 ? "odd" : "even";
var int indent = ($c.depth - 1) * $no_indent_pixels;
if ($c.depth >= $no_indent_depth) {
$indent = $no_indent_depth * $no_indent_pixels;
}
"<div class='comment-thread comment-depth-$parity comment-depth-$c.depth'>\n";
"<div id='$c.dom_id' style='margin-left: ${indent}px; margin-top: 5px'>\n";
if ($c.full) {
$this->print_comment($c);
} else {
$this->print_comment_partial($c);
}
"</div>";
$this->print_comments($c.replies);
"</div>";
}
}



var int no_indent_depth = 16;
In this example, the comments will stop indenting after reaching a comment depth of 16.

var int no_indent_pixels = 16;
Here, comments will indent 16px from the parent comment. The default indentation is 25px.

This is based on a theme mod from LJ that I really liked and tried to apply it to DW. The original also linked the comments, but I'm not sure how to do that here. If you have any questions, let me know. I'll try my best answering them.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting