Questions tagged [comments]
Use it for questions about the comment entity.
844
questions
0
votes
0
answers
17
views
Ordering comments on a forum topic by rating provided by Rate module, whilst retaining the correct threading
I have a forum with threaded comments. Each comment has a like button provided by the Rate module (which uses the Voting API).
I want to order the comments on the forum post by the rating count value. ...
0
votes
0
answers
20
views
Is it ok to share a comment field with multiple content types?
Imagine I want to convert individual forum threads (topic + comments) into a content type 'Blog post' to preserve them for the long term.
In order to make this work, the comment field of 'Blog post' ...
0
votes
1
answer
172
views
What is the meaning of "fields pending deletion"?
I have a Drupal 9.5.3 installation which is not customized in any way; no custom modules or themes.
I want to remove the Comment core module but I can't and the reason that is given is:
Fields ...
-3
votes
1
answer
45
views
Does Drupal core include any comment spam prevention mechanism?
I have a Drupal 9 core website and I have allowed comments in it (approval needed).
The problem is that my website is flooded with spam boots posting links in pre-approved comments. This causes burden ...
0
votes
1
answer
121
views
Stick comments on top
I need to stick specific comment on top of others which will remain from oldest to newest.
When it's stick on top it's replies must be with that comment.
So
I made links in .module file which will ...
0
votes
0
answers
30
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
34
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....
0
votes
3
answers
105
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
69
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
36
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 ...
2
votes
2
answers
91
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
1
answer
365
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
81
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 ...
0
votes
1
answer
70
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
123
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
117
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
210
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 ...
0
votes
1
answer
50
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['...
1
vote
2
answers
554
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 ...
1
vote
2
answers
629
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 ...
0
votes
1
answer
29
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 ...
1
vote
1
answer
66
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 ...
1
vote
1
answer
208
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 %}...
0
votes
1
answer
104
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 ?
0
votes
0
answers
73
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 ...
0
votes
1
answer
118
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
126
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
688
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 ...
0
votes
1
answer
42
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 ...
0
votes
2
answers
176
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?
1
vote
1
answer
67
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 ...
1
vote
0
answers
212
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 ...
2
votes
1
answer
696
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 ...
0
votes
0
answers
127
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
104
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
177
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 ...
0
votes
1
answer
83
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 ...
1
vote
1
answer
385
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 ...
0
votes
1
answer
234
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
545
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
159
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
491
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 ...
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 ...
1
vote
1
answer
528
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 ...
0
votes
1
answer
103
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 }}
...
1
vote
0
answers
62
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 ...
1
vote
1
answer
38
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....
3
votes
1
answer
593
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 ...
-1
votes
1
answer
35
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 ...
1
vote
1
answer
821
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 :