Questions tagged as ['comments']

Use it for questions about the comment entity.
Score: 1
Confirmation message on comment submission
in flag

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 this code.

function mymod_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  else if ($form_id == 'comment_comment_form') {
    $form['actions']['submit']['#value'] = "your comment has been ...
Score: 0
Plugin not found
in flag

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 bulk form element.
 * @ViewsField("custom_comment_bulk_form")
class CustomCommentBulkForm extends CommentBulkForm {

   * {@inheritdoc}
  protected function emptySelectedMessage() { ...
Score: 0
getCommentedEntity returns null
in flag

I have a comments page set up and when I devel the page for a specific comment I see the getcommentedentity method. enter image description here

I am trying to get the commented entity details using the below code in my VBO action file:

public function execute(ContentEntityInterface $entity = NULL) {
    $comment = $entity->get('comment_body')->getValue();
    $commentid = $entity->get('cid')->getValue();
    $va ...
Score: 1
Bharat avatar
Comments on user profile not working
mp flag

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 showing empty. What is the correct way to allow other users to give comments on user profiles?

Score: 1
Karthik avatar
How do I get the comment ID in a template file?
in flag

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 %}
      {{ title_prefix }}
      <h3{{ title_attributes }}><a href="#comment-{{}}">{{ title | render | striptags}}</a></h3>
      {{ title_suffix }}
    {% endif %}
Score: 0
steevee666 avatar
How do I modify the permissions assigned to a comment type?
in flag

On my Drupal 9 site, I created 2 types of comments:

  • comment_type_a
  • comment_type_b

When I go for permissions, there are only permissions for all comments in general.

How do I modify the permissions assigned to a comment type?

I want for comment_type_a only admin role can comment.

I want for comment_type_b all roles to be able to comment.