From 1289bd8a1a8b2f3e27f50278475e35eea84d615f Mon Sep 17 00:00:00 2001 From: Gerhard Killesreiter Date: Wed, 3 Jan 2007 21:56:58 +0000 Subject: [PATCH] #18870, Comment module outputs duplicate IDs for all *new* comments, backport --- modules/comment.module | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/comment.module b/modules/comment.module index 97c2a0248a9..afe9842f1d5 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -1465,10 +1465,14 @@ function theme_comment_preview($comment, $links = array(), $visible = 1) { }; function theme_comment_view($comment, $links = array(), $visible = 1) { + static $first_new = TRUE; - // Emit selectors: $output = ''; - if (($comment->new = node_mark($comment->nid, $comment->timestamp)) != MARK_READ) { + $comment->new = node_mark($comment->nid, $comment->timestamp); + if ($first_new && $comment->new != MARK_READ) { + // Assign the anchor only for the first new comment. This avoids duplicate + // id attributes on a page. + $first_new = FALSE; $output .= "\n"; }