When a user replies to a comment, the script very usefully includes a link to the comment to which we are replying. This link works fine, but the comment post number displayed is incorrect. The comment post number is calculated in _advanced_forum_preprocess_comment(). I have no idea what the error is caused by but I found a solution by creating my own template_preprocess_comment() with the following code in it

  static $post_positions;
  $comment = $variables['comment'];
  $node = node_load($comment->nid);
  $posts_per_page = _comment_get_display_setting('comments_per_page', $node);
  $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
  if (!$page_number) {
    $page_number = 0;
  }
  /* Linked post number */
  if (!isset($post_number)) {
    static $post_number = 1;
  }
  $post_number++;
  $post_positions[$comment->cid] = ($page_number * $posts_per_page) + $post_number;
  /* In reply to */
  $variables['in_reply_to'] = "";
  if ($comment->pid > 0) {
    // Find the display position of the parent post;.
    $post_position = $post_positions[$comment->pid];
    // This extra if test is a sanity check in case the comment being replied
    // to no longer exists.
    if ($post_position > 0) {
      // Find the page the post is on. We need to compensate for the topic node
      // being #1 which puts an extra post on the first page but not on the rest.
      $page_number = floor(($post_position - 2) / $posts_per_page);
      // Assemble the link.
      $fragment = 'comment-' . $comment->pid;
      $query = ($page_number) ? 'page=' . $page_number : NULL;
      $linktext = t("(Reply to #!post_position)", array('!post_position' => $post_position));
      $linkpath = "node/$node->nid";
      $variables['in_reply_to'] = l($linktext, $linkpath, array('query' => $query, 'fragment' => $fragment));
    }
  }

Rather than attempt to recalculate the post number from scratch, here we simply store the post number against it's comment cid so that we recall it when needed. Since a comment is always going to appear before any replies made to it, then we will always have the info we need for this.

The module maintainer might consider changing _advanced_forum_preprocess_comment() to process the post number using this method.

Comments

Status:Active» Postponed (maintainer needs more info)

I can't reproduce this. I've tested this quite a bit and the comment number is always correct. Do you have a link to the site where it is incorrect?

Your "solution" will fail if the comment isn't on the same page, which is why AF has the more complicated calculating method.

Michelle

I've disabled my fix and here is a link to the forum: http://74.53.52.240/node/335#comment-1

Category:bug» support
Status:Postponed (maintainer needs more info)» Fixed

Oh, I see what the problem is. Your replies aren't in order. I can't even tell what order you have them in. The dates are all over the place. They need to be in date order ascending in order for the "in reply to" to work.

I created an account to test before I realized what the problem was. You can go ahead and delete it.

Michelle

Do you mean ordered by date - oldest first (asc) rather than date - newest first?

I have switched it to oldest first, and still get irregular results. Also note that this is a threaded list not a flat list. If I change to a flat list then reply-to number is correct. So it is possible that your reply to calculation works for flat lists but not threaded.

I've made you super admin so that you can change the comment settings and see for yourself. I note that this is version 2.x.dev and it might be different in the alpha versions.

BTW I also tested the code I created using multiple pages of comments and it works except the first comment on subsequent pages has no reply-to number at all. This probably can be overcome. Currently my fix is disabled and the forum has native functionality.

Yes, it must be a flat list as well. It didn't look threaded when I looked at it so I didn't think to mention that.

This functionality doesn't exist in any alpha. It's very new.

Michelle

Yes, sorry it doesn't look threaded because I disabled the indentation. Without the indentation the reply-to numbers are important. We'll keep using our fix and now that you know about this then it's up to you what you do.

Thanks very much

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Category:support» bug
StatusFileSize
new140.17 KB

Hi,
I'm reopening this issue, it is still wrong in 6.x-2.0-alpha4, I assume this has not been fixed in dev
It happens using "oldest first" sort, flat and nested.
I've attached a screenshot.

Thanks.

Status:Closed (fixed)» Active

You hadn't actually reopened the issue. I'll take a look at this ASAP.

Thanks for your help as the new maintainer, mcdruid.
Sorry, seems that I didn't change the status properly.

Status:Active» Closed (won't fix)

birwell, as far as I can see from your screenshot, you've got comments set to threaded (I'm saying this because of the visible indentation; I can see that the comments are shown in date order).

As mentioned in Michelle's replies above, under 'Comment settings' the README for advanced forum says:

* Set Default display mode: Flat list - expanded. (Advforum is intended to be used
flat. Using it threaded should mostly work but is unsupported and may have some
issues.)

Hello mcdruid,
yes, the screenshot is nested, but as I told in the post I tested it using flat and nested modes and the result was the same.
I think the problem is the "oldest first" option.
Cheers!

Status:Closed (won't fix)» Needs review
StatusFileSize
new2.52 KB

Duplicate related to 7.x-2.x-dev: http://drupal.org/node/1724080

I'm attaching patch from http://drupal.org/node/1724080#comment-6338614, that have been ported to 6.x-2.x-dev. It works fine on my D6 installation, please review and commit to 6.x-2.x-dev.