Questions tagged [comments]

Use it for questions about the comment entity.

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

Report comments / Workflow

I am trying to implement a functionality that would allow authenticated users to report comments on a forum post. My first thought was to do it using workflows but comments dont have a workflow ...
1 vote
1 answer
20 views

Module template for a comment field is not triggering comment_preprocess_field

I have a custom module in which I am trying to override a comment field's template in Drupal 9.3. In my module file I have defined the hook_theme to override the core template in use. (comment.html....
  • 191
0 votes
3 answers
86 views

How to add some content every Nth comment?

My use is case is that I wish to show an advert every 3rd comment. The forum module added the comment field to the forum content type. So the field name is comment_forum. I have a block that contains ...
1 vote
2 answers
26 views

How to hide the "Add new comment" link on the add new comment page

In Drupal 8+, the "Add comment" form can be shown on a separate page by going to Manage fields for the content type that has comments and unchecking the box Show reply form on the same page ...
1 vote
0 answers
23 views

Comments form won't appear

I'm switching a website from Disqus back to the regular Comment module. After installing the module, I can configure it just fine as an administrator and add comments on some dummy articles. But when ...
3 votes
2 answers
65 views

How to hide the comment subject field?

In Drupal 7, there used to be a checkbox: "Allow comment title". Unchecking that, and there was no comment title. I am unable to locate a similar setting in Drupal 9. I've found: How to ...
0 votes
0 answers
32 views

How to restrict access to comment form and posted comments for certain users

I have a content type where comments are enabled. So on node view, I can see the comment form and all the posted comments. Is it possible to not display the comment form and all the posted comments ...
  • 2,765
0 votes
1 answer
199 views

How to remove or hide the Subject field for comments?

I have added a comment field to a content type. It is of the default comment type. I don't want my commenters to fill in a subject, rather, just a comment body. Trying to remove the Subject field, I ...
2 votes
2 answers
62 views

How do I display user signatures in comments?

Drupal 7 has a "personalization" section on ...admin/config/people/accounts If this exists in Drupal 9, I'd love to know where it is. The goal: enable signatures for user accounts. If it's ...
  • 193
0 votes
0 answers
28 views

Comment not displaying on node where nid integer is greater that 6 digits

I have a D7 website, and have found that comments won't display on nodes where the nid is > 6 digits (affects only 2 of 6 content types). The site is updated to the latest version, hosted on an ...
  • 1
0 votes
1 answer
64 views

How do I get a list the comment types' machine name?

Drupal ships with just one comment type enabled, with the machine name comment. But if the Forum module is installed, there is also comment_forum. And site builders can define new comment types in the ...
1 vote
2 answers
98 views

View only your own comments, no one else's?

I have a client who would like users to be able to comment on content without being able to see any other users' comments. This is for a review system where users shouldn't feel influenced by the ...
1 vote
2 answers
87 views

How can I get Average of a comment field by node_id?

I have Comments here wherein user can rate a content. I want to get the average rating per content, how do I efficiently get the average? I have the following code to get the Average: $cids = \Drupal::...
2 votes
1 answer
152 views

How can I enable workflows for comments?

I would like to create workflows for comments and moderate them, but I can't find comments under This workflow applies to: on /admin/config/workflow/workflows/manage/comment_workflow. Does anyone know ...
  • 37
0 votes
1 answer
49 views

Display comments only for users with "administer comments" permission

In hook_node_view_alter, I'm trying to restrict the display of comments to users who have the "administer comments" permission. So far I have this but it is not working. if (isset($build['...
  • 23
1 vote
2 answers
379 views

Confirmation message on comment submission

When a comment is submitted, no confirmation message is shown and I would like to achieve this. I want to show the following message. Your comment has been added for review and approval. I tried ...
  • 33
0 votes
1 answer
190 views

Plugin not found

I am overwriting the CommentBulkForm class in my module. namespace Drupal\mymod\Plugin\views\field; use Drupal\comment\Plugin\views\field\CommentBulkForm; /** * Defines a custom comment operations ...
  • 33
0 votes
1 answer
27 views

getCommentedEntity returns null

I have a comments page set up and when I devel the page for a specific comment I see the getcommentedentity method. I am trying to get the commented entity details using the below code in my VBO ...
  • 33
1 vote
1 answer
65 views

Comments on user profile not working

I want to add comments to user profiles. I added the comments in user profile under Configuration > People > Account settings, but when I add the field, the option to select the comment type is ...
  • 302
1 vote
1 answer
140 views

How do I get the comment ID in a template file?

I want to show the comment title linked to the comment permalink. This is the content of the comment.html.twig file. <div{{ content_attributes.addClass('comment__content') }}> {% if title %}...
  • 13
0 votes
1 answer
70 views

How to remove comments from all nodes

I want to remove the comment section from all my articles. Can this be done with an sql query or something so I don't have to do it manually by setting comments to disabled ?
  • 1
0 votes
0 answers
55 views

Option to set comments to Hidden on an individual piece of content (node), even when it has no comments

Drupal 8 and Drupal 9 comment fields provide three settings for the default, as configured at for example /admin/structure/types/manage/article/fields/node.article.comment: The default value for this ...
  • 1,352
0 votes
1 answer
87 views

How to get comment cid in hook_comment_insert?

I've read the answers to How to get the node id the comment is attached to in hook_comment_insert? and found how to extract the nid of the node the comment is associated with. However, I also need to ...
1 vote
0 answers
110 views

How do I fetch all users in a comment thread?

I want to send notifications to users that have posted in a comment thread. I need to get the user IDs in an event subscriber that will be triggered when comments are created/edited, so performance ...
0 votes
1 answer
305 views

Incorrect string value: '\xF0\x9F\x92\x99' for column "'comment_body_value'"

How can I fix the following error I get from a Drupal 7 site? Incorrect string value: '\xF0\x9F\x92\x99' for column "'comment_body_value' I read it is about users posting emojis that cannot be ...
  • 41
0 votes
1 answer
35 views

Render published content or comments on new created content using a link

I was looking without luck for a way to be able to make a link or button with the functionality of making a new content showing some content or comment already posted above, something like the Retweet ...
  • 75
0 votes
2 answers
135 views

Hide comment box from node for Anonymous users

I am trying to hide the comment box for anonymous users. Anonymous users should only be able to view the comments. How can I hide the comment form?
  • 27
1 vote
1 answer
49 views

How do I add a view between display fields of a node?

I have a view that displays a table at the bottom of every node. It's part of the content of the node so I want to have the "comments" section below the view. However, the comments are a ...
  • 548
1 vote
0 answers
158 views

How to extend existing 'access comments' permission?

I am trying to extend access to comments based on the entity they are attached to. I have created permissions in my permissions.yml file as following. view user comments: title: 'View comments ...
  • 111
2 votes
1 answer
556 views

How can I add a comment form?

I'm using views to display the fields of nodes. I prefer to use fields because it allows me to use relationships (bring in author profile picture etc.). Adding the Content: Comments field shows the ...
  • 471
0 votes
0 answers
109 views

Custom jQuery action on AJAX events

I'm trying to use a custom javascript event when certain actions are performed on my site, specifically things like Webforms, or Node Comments being submitted (both of which are setup to submit via ...
4 votes
2 answers
82 views

Alter comment pager to jump to comment section right away?

I set up a content type and a specific comment type for this content. I set the comment pager to display 10 comments per page. When I now use the pager, I get redirected from the node URL itself www....
0 votes
1 answer
152 views

How can I automatically flag new comments?

I have a Drupal 8 site with Flag and Rules modules. How to flag a new comment ? I want that when a user creates a comment, the comment should be automatically flagged. I created a type of Flag on the ...
  • 61
0 votes
1 answer
62 views

'Add new comment' link/button does not display on custom entity

A new comment type is created and added as a field (say x_comments) to a custom entity. The comments show up and work as expected. However when the x_comments field is configured to disable 'Show ...
  • 444
1 vote
1 answer
313 views

How to print "node title" in comment.html.twig template?

i am styling my comments in comment.html.twig template and need to show "node title" of the node to which the comments belong. I've tried a number of options, and the only one that works ...
  • 179
0 votes
1 answer
141 views

How to hide "Log in or register to post comments" when I've already disabled displaying comments?

I already disabled comments. How can I remove the "Log in or register to post comments" text at the bottom of articles or other content types?
1 vote
1 answer
460 views

twig template suggestion for comment reply form

there is no template suggestion for a comment reply form in Drupal 8, how can i create one? i am not talking about the reply form displayed in the node for which Drupal suggest a template : field--...
1 vote
1 answer
145 views

Allow comments only for the author of the node

I'm using Drupal 8 for a personal project and I'd like to allow only the node author to post comments. Can you please help? I'm stuck.
1 vote
1 answer
416 views

Display comment form without the comment thread

What are some ways of rendering a comment form without also displaying the comments? What about creating a block contains the form? If that's possible, what are some links to documentation touching ...
  • 433
0 votes
0 answers
28 views

Is there an easy way to programmatically add a comment field to a content type? [duplicate]

I currently have the following code in a D8 module: $sql = 'CREATE TABLE `comment__field_follow_up_date` (' . "`bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field ...
  • 123
1 vote
1 answer
453 views

Show Comment Form on its own Page or Popup

I am trying to figgure out how to show the comment form on its own page. So far I have been able to show it on a seperate page. All I had to do was to go to field comment setting and uncheck "Show ...
  • 599
0 votes
1 answer
94 views

How to display an alternative text if the comments are closed for the node?

in my node type template, how do I display alternate text if comments are closed for the node ? {% if content.comment %} <div class="card mb-5 p-3 shadow"> {{ content.comment }} ...
user avatar
1 vote
0 answers
37 views

How to add custom query to comment entity

I have comment thread field attached into a node. I would like to have a search function by keyword. I used hook_query_TAG_alter() to add database condition according to my needs. Here's my current ...
  • 334
1 vote
1 answer
34 views

Add text message under "Add new comment" title

I would like to add a disclaimer message under "Add new comment" title and above the form in drupal 8 site. I changed the help text on this path /admin/structure/types/manage/article/fields/node....
  • 109
3 votes
1 answer
496 views

Where do I find the comment IP address?

I am searching for comments ip address in D8 and I can't find where they are located in database. In D7 it was easy to find. Is there a chance that D8 is not storing the commenters ip address? If it ...
  • 109
-1 votes
1 answer
30 views

Commenting or replying a specific node without the possibility of commenting others?

I built a website sort of like an online directory for restaurants in my home town, and I am letting the users to leave their reviews about a specific restaurant, and what I need is to give access to ...
0 votes
1 answer
691 views

How to count the number of comment and flag in a node?

I want to display on my node the number of comment and flag. What should I add to my TWIG to get this? How to count the number of comment and flag in a node? Here is an example :
0 votes
1 answer
93 views

Add a Radio-button with other option in comment type

I have the following requirement in Drupal 8: I have to create a comment type with options. In options there will be a Other option on whose click a text field will be opened. something like below ...
  • 23
0 votes
1 answer
272 views

How can I prevent "Log in to post comments" from displaying for anonymous users?

How do I remove the "Log in to post comments" from the bottom of my content in Drupal 8 while keeping old comments visible to all and allowing existing registered users to still comment? ...
  • 331
0 votes
1 answer
107 views

How can I display the time passed since a comment was created instead of the creation date?

how to personalize my comments ? I want to display since when the comment was created instead of the date. I want to display the comment ID with the link "permalink". Can you help me ? Thank you ...

1
2 3 4 5
17