diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index bada6ed2c52d81aa6057b1fa864571d473990830..02b7906464d62f390b337539252cb46758694474 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -667,13 +667,17 @@ function comment_node_view($node, $view_mode) { } } if ($node->comment == COMMENT_NODE_OPEN) { + $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW); if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), - 'href' => "comment/reply/$node->nid", + 'href' => "node/$node->nid", 'attributes' => array('title' => t('Add a new comment to this page.')), 'fragment' => 'comment-form', ); + if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) { + $links['comment-add']['href'] = "comment/reply/$node->nid"; + } } else { $links['comment-forbidden'] = array( diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test index 5497dcc9dc3afd670340cd5df323e9dccad6030e..ad7aa4fd365e4c453e98c00af7b519ed5f7dec79 100644 --- a/core/modules/comment/comment.test +++ b/core/modules/comment/comment.test @@ -920,6 +920,17 @@ class CommentInterfaceTest extends CommentHelperCase { } else { $this->assertLink('Add new comment'); + + // Verify that the "Add new comment" link points to the correct URL + // based on the comment form location configuration. + if ($info['form'] == COMMENT_FORM_SEPARATE_PAGE) { + $this->assertLinkByHref("comment/reply/$nid#comment-form", 0, 'Comment form link destination is on a separate page.'); + $this->assertNoLinkByHref("node/$nid#comment-form"); + } + else { + $this->assertLinkByHref("node/$nid#comment-form", 0, 'Comment form link destination is on node.'); + $this->assertNoLinkByHref("comment/reply/$nid#comment-form"); + } } // Also verify that the comment form appears according to the configured