Page 1 of 1

Beginner Question about Nested Comments

Posted: Fri May 26, 2006 3:12 pm
by drx
Hi, i would like to know if it is possible to change the display of nested comments into a real nested HTML list. You know, something like

Code: Select all

<ul>
 <li>#1
   <ul>
    <li>#1.1</li>
   </ul>
 </li>
 <li>#2</li>
</ul>
So the markup would actually represent the nesting structure.

I didn't really get if the markup produced by all the sites using s9y is a built-in freature or if it can be changed in any way ...

Best greetings,
drx

Re: Beginner Question about Nested Comments

Posted: Fri May 26, 2006 3:29 pm
by garvinhicking
Hi!

Since nesting elements like this imposes many problems in browsers (especially concerning padding/margins and wrapping) we went the way to "walk" a nested array and build it into a sequential array with numbers indicating the nesting "depth" level.

This can then be edited in the "comments.tpl" template file. I think you could be able to use that sequential order to build the nested order again using smarty markup, but that's certainly some work to do.

The bottom line is, I wouldn't recommend it, just because of the sake of nested items. The nesting can properly be indicated with CSS, and with much more control than the other way, so I don't see a pressing reason why to take on that building. Recursion is certainly slower in this case than just indexed sequences...

HTH,
Garvin

Posted: Fri May 26, 2006 7:13 pm
by carl_galloway
Check out the comments.tpl in my Dusk theme. It isn't exactly what you want but might give you some inspiration.

Re: Beginner Question about Nested Comments

Posted: Sat May 27, 2006 12:05 am
by drx
Hi, thanks for your answer!
This can then be edited in the "comments.tpl" template file. I think you could be able to use that sequential order to build the nested order again using smarty markup, but that's certainly some work to do.
So it is possible to access this depth level somehow?

Some time ago i used this logic to create a nested comment list with the same data available:

Code: Select all

$Level = 0;
foreach(array_keys($Entries) as $Key)
	{
	if($Level != $Entries[$Key]['Level'])
		{
		if($Level>$Entries[$Key]['Level'])
			{
			while($Level > $Entries[$Key]['Level'])
				{
				echo "</li>\n</ul>\n";
				$Level--;
				echo "</li>\n";
				}
			}
		else
			{
			while($Level < $Entries[$Key]['Level'])
				{
				echo "<ul>\n";
				$Level++;
				}
			}
		}
	else
		{
		echo "</li>\n";
		}

        // actual comment goes here
 
    }

	while($Level > 0)
		{
		echo "</li>\n</ul>\n";
		$Level--;
		}
The bottom line is, I wouldn't recommend it, just because of the sake of nested items. The nesting can properly be indicated with CSS, and with much more control than the other way, so I don't see a pressing reason why to take on that building. Recursion is certainly slower in this case than just indexed sequences...
Recursion wouldn't be needed, if i understand correctly what you said about the flat array.

I think the argument about problems with display are not really valid, with some more lines of CSS all the issues can be fixed and the HTML would actually have a meaning instead of being just a lot of DIVs. It would also work without any stylesheets at all. Also through proper nesting Javascripts could be introduced to display/hide subtrees of a discussion.

It just looks extremely weird to have the software generate a "1.1" kind of numbering when this is one of the few things that HTML can actually do by itself through markup! :)

I recommend using "correct" nesting by default. I was happy to find a blog software where nested comments are a core feature because i want something to enable discussions; i really think all these flat comments all over the web are a huge step backwards.

Best greetings,
drx

Re: Beginner Question about Nested Comments

Posted: Sat May 27, 2006 11:50 am
by garvinhicking
Hi!

Yes, the depth can be acceessed in comments.tpl through smarty via:

Code: Select all

{$comment.depth}
About the nesting: My experience from nested <ul>s in the past was, that it created more trouble than it solved. If you get it all properly working, all the better. Maybe you could show the final result to us, so that we could check it in a few browsers and see about using that in the future for the default?

HTH,
Garvin

years later ...

Posted: Mon Sep 03, 2007 8:37 pm
by drx
... i finally made a template for nested comments. It works well, only based on smarty and the $comment.depth variable. Also, i used jQuery to let the comment form appear right under the comment you want to reply to, but it still works without javascript turned on in the classic s9y way.

Is there a place to show this code around?

(I helped coding some discussion forums before that used nested lists and it all worked out, even in Netscape 4, with hundreds of comments.)

bests, drx

Posted: Tue Sep 04, 2007 5:47 am
by Don Chambers
drx - post a download link to your code so we can check it out if you can.

Test it here ...

Posted: Tue Sep 04, 2007 8:46 pm
by drx
Hello,

the theme's code is here:
http://nm.merz-akademie.de/~dragan.espe ... ravers.zip
It works mostly for my needs but is not ready for a proper release.

You can try the nested comments on this post if you like:
http://nm.merz-akademie.de/~dragan.espe ... stars.html
It's localized in German, click "Antwort" to post a reply or fill the form.

Tested in Firefox 2.x, IE 6+, Opera 9.2+, Konqueror 3.5.7 ... my experience is that if it works in Konqueror, it works everywhere ;)

Bests,
drx

Posted: Tue Sep 18, 2007 9:15 am
by mark007
Thanks a lot