"In reply to" anchor link
| Project: | Advanced Forum |
| Version: | 6.x-2.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I've been admiring the Drupal based forums on nowpublic.com...
They have a feature in the comments that creates a link from a comment to its parent comment. For example:
http://www.nowpublic.com/newsroom/forum/we-are-launching-new-flagging-sy...
Is something like this possible using theming alone with AF? or do you figure they are using some sort of custom template pre-process?
I suppose it's possible to a within page anchor link as follows:
<?php
print '<a href="' . $_SERVER["REQUEST_URI"] . '"#"' . $comment->pid . ">In reply to</a>";
?>But I fail to see how this site is linking back to previous pages as in the link above. The whole paging thing in comments has me stumped :(
Also, (perhaps this is related), in advf-forum-post.tpl.php there's a variable $page_link
Anybody know what that's for?
Thanks,
Mike

#1
The NP folks are willing to share (some of?) their forum tweaks with the community so I'm going to talk with them sometime in the next couple of days. Some of it will likely end up in AF 2.x. This particular feature is not one I personally have a use for since I force all my forums flat. Assuming they're willing to share that part, I'll see how they did it and add it if it's simple enough or might end up just posting the code for someone else to write a patch for. AF is currently in feature freeze, though, so it won't be until 2.x.
Michelle
#2
Thanks Michelle! I'll be watching closely for that.
Aren't the NP forums flat also? Seems this feature is meant for flat forums that list comments sequentially and not threaded. My forums (http://www2.swaylocks.com/forum) are flat and that's why I want to do this. It's a feature my members have complained they miss since migrating from Gossamer Threads Forums.
I'm pretty sure NP is using a custom filter to perform this. On the NP site, when you reply to a comment, it automatically gets quoted in the reply field like this:
[qc pid=58483] quoted text here... [/qc]I'm just curious where and when the formatting of the "in reply to..." takes place...is it upon submission of the comment and hence saved in the db in some way? or is it late in the load sequence and parsed on loading the comment. I tend to think saving the information would be more efficient...
I've been working on this problem for two days (am I slow or what?) and here's where I'm at. Again this assumes flat comments.
It's easy to find out the pid of a comment -- what's hard is creating a good link to that comment that has the correct page number. Seems to me, the only way to do that is to know where in the chronological sequence of comments (1st, 2nd, 3rd) a parent comment has occurred. For example, the parent of the comment 50 was comment 6. At 20 comments per page, parent page is page 1.
Currently, in the Drupal forums (& AF) there's no built in way to figure out where in the sequence of comments (1,2,3,4,5,...) an individual comment lives in order to create that link.
It seems to me advanced_forum_preprocess_comment is the best place to do that. The $100k question is how to do it...I see two options:
1. Create a sorted array of the timestamps for all the comments on a node, find the location in that sequence, create the in reply to link using that info. Increase efficiency by creating a static variable (array) for each page load. (Is this hugely inefficient if a node has 1000 comments?)
2. Custom module. Create a new table that has cid and comment number (& possibly nid) that gets filled upon hook_comment(save). Load up that count number on hook_comment(view). Retrieve this count number to create the link.
I've been working on #2..though, admittedly, my brain is starting to hurt and I may be stuck in the forest. Perhaps theres a much easier, more creative way to do this.
Anyhow...that's where I'm ad. Sorry for the brain dump. No need to reply unless a light bulb pops over your head.
Mike
#3
Well, comments only have parents in a threaded forum. The only way to do it in a flat forum would be to grab the comment being replied to at the time of the replying and save the "parent" id somewhere. I have no idea if the NP forums are flat and I won't know what method they're using until I see the code.
Michelle
#4
Then I must be thoroughly confused. :(
Is a "flat forum" synonymous with "flat list expanded" found in the comment controls block? (hidden on my forums)
If so, then comments do have parents in a flat forum -- the parent is the comment that is replied to. And that comment id is saved in the pid column whether you display your forum flat or threaded. I'm pretty sure that's what is going on, however I may be confused here.
#5
Doh! I bet you mean this:
http://drupal.org/project/flatcomments
#6
I meant truly flat, not a threaded forum just dislplaying flat. That's what flatcomments does, yes. Displaying a threaded forum flat causes odd problems and is really not recommended.
I've had a look at the NP code and it's definitely non trivial. I'm not going to totally won't fix this because it's an interesting feature and I may tackle it at some point. But postponing it because it won't be any time soon. I'm still trying to get confirmation on whether I can share the code. If you're interested in trying it yourself, shoot me an email and I'll send you the code if I get the green light.
Michelle
#7
To update: I did get permission. So let me know if you want the file.
Michelle
#8
This may be discussed elsewhere, however this seems like a good enough context for this question...
Do you know if I can install Flatcomments on an existing forum without all hell breaking loose?
Thanks again,
Michael
#9
You can, but I don't know if it will work retroactively. All it does is force the pid of all comments to be 0 so they're all children of the node no matter what reply link is clicked.
I got your email but can't send out from here. I'll reply when I'm home later this evening.
Michelle
#10