When a node is shown in the book module then the "Add comment" link is displayed at the bottom of the node. This is unnecessary when comments already exist because then the comment form with "add comment" field and button is already shown on the page.

The Bartik theme seems to fix this with the following snippet. We should probably implement this in socialbase as well.

/**
 * Implements hook_preprocess_HOOK() for node.html.twig.
 */
function bartik_preprocess_node(&$variables) {
  // Remove the "Add new comment" link on teasers or when the comment form is
  // displayed on the page.
  if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
    unset($variables['content']['links']['comment']['#links']['comment-add']);
  }
}

Comments

Kingdutch created an issue. See original summary.

Evelienschut’s picture

Btw from the customer: removing the ADD NEW COMMENT link makes the most sense.

brhane’s picture

Assigned: Unassigned » brhane
ronaldtebrake’s picture

Assigned: brhane » Unassigned
Issue tags: +Novice
ritzz’s picture

Assigned: Unassigned » ritzz
rajesh kairamkonda’s picture

Removed the "ADD NEW COMMENT" link

rajesh kairamkonda’s picture

Status: Active » Needs review
ritzz’s picture

Assigned: ritzz » Unassigned
kingdutch’s picture

Status: Needs review » Needs work

I'm going to mark this as needs work for a few reasons. I've not done any manual testing but only done patch review.

  1. The current patch looks like it has some issues with whitespace (coding standards)
  2. The code lacks a comment on why it removes the "Add comment" link (coding standards)
  3. In socialbase we use the Bootstrap Preprocess classes instead of the preprocess hook
  4. This looks like it will affect a lot more than just the book and could break other things. The implemented solution is a lot different from Bartik even though I don't expect the solution to be very different.
shubham_narlawar’s picture

Issue tags: +Add Comment
kingdutch’s picture

Issue tags: -Add Comment

From the instructions beneath the "Issue tags" field. Please

Do NOT use tags for adding random keywords or duplicating any other fields.

left’s picture

Assigned: Unassigned » left
left’s picture

StatusFileSize
new89.39 KB
new191.06 KB

I see two things happening and I am note sure which is relevant. Maybe both.

1. When on the full node, and there is a comment already on the page, we see a "Add new comment" button. I think this serves to take us to the comment form. It's inconsistent with other content types, as far as I can see.

Book full node with add comment button

2. On the teasers, we see a comment count in text, and we see an "Add comment" button. This is inconsistent with the other teaser

Book teaser with add comment button

Is it correct that in both cases, we don't want the "Add new comment" button to appear?
And that the comment count should be removed from the teaser (in favour of the icon comment count)?

left’s picture

Assigned: left » Unassigned
Status: Needs work » Needs review

I attempted to implement the snippet from Bartik and didn't get results. I changed the template to Bartik and the Book node pages were not affected. I am not sure why this is. A second opinion would be good.

So, I have two proposed solutions - both are incomplete

1. In the Link preprocess class, I can remove all add-comment and comment-comments (code in currently commented out)
This would affect all nodes.
https://github.com/goalgorilla/open_social/pull/796/files#diff-204941b91...

2. In the Node preprocess I can unset links for Book teasers. This means I need to manually add a read more button to the template.This is not done yet
https://github.com/goalgorilla/open_social/pull/796/files#diff-c0c92d787...

PR is here https://github.com/goalgorilla/open_social/pull/796

Input welcome.

left’s picture

I have opted for option 1.

1. In the Link preprocess class, I can remove all add-comment and comment-comments (code in currently commented out)
This would affect all nodes.

PR is waiting for review.
https://github.com/goalgorilla/open_social/pull/796

jaapjan’s picture

Status: Needs review » Fixed

Thank you all, just merged the pull request!

  • left authored f44c0f1 on 8.x-1.x
    Issue #2938566 by Rajesh Kairamkonda, left, Kingdutch: remove comment...

Status: Fixed » Closed (fixed)

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