function template_preprocess_comment_wrapper

Prepares variables for comment wrapper templates.

Default template: comment-wrapper.html.twig.

Parameters

array $variables: An associative array containing:

  • content: An associative array containing render arrays for the list of comments, and the comment form. Array keys: comments, comment_form.

File

drupal/core/modules/comment/comment.module, line 1709
Enables users to comment on published content.

Code

function template_preprocess_comment_wrapper(&$variables) {

  // Provide contextual information.
  $variables['node'] = $variables['content']['#node'];
  $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED);

  // The comment form is optional and may not exist.
  $variables['content'] += array(
    'comment_form' => array(),
  );
  $variables['attributes']['id'] = 'comments';

  // Add a comment wrapper class.
  $variables['attributes']['class'][] = 'comment-wrapper';

  // Create separate variables for the comments and comment form.
  $variables['comments'] = $variables['content']['comments'];
  $variables['form'] = $variables['content']['comment_form'];
}