Skip navigation


7 comment.module comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL)

Builds a structured array representing the comment's content.

The content built for the comment (field values, comments, file attachments or other comment components) will vary depending on the $view_mode parameter.


$comment: A comment object.

$node: The node the comment is attached to.

$view_mode: View mode, e.g. 'full', 'teaser'...

$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.

1 call to comment_build_content()


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


function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;

  // Remove previously built content, if exists.
  $comment->content = array();

  // Build fields content.
  field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode);
  entity_prepare_view('comment', array($comment->cid => $comment), $langcode);
  $comment->content += field_attach_view('comment', $comment, $view_mode, $langcode);

  $comment->content['links'] = array(
    '#theme' => 'links__comment', 
    '#pre_render' => array('drupal_pre_render_links'), 
    '#attributes' => array('class' => array('links', 'inline')),
  if (empty($comment->in_preview)) {
    $comment->content['links']['comment'] = array(
      '#theme' => 'links__comment__comment', 
      '#links' => comment_links($comment, $node), 
      '#attributes' => array('class' => array('links', 'inline')),

  // Allow modules to make their own additions to the comment.
  module_invoke_all('comment_view', $comment, $view_mode, $langcode);
  module_invoke_all('entity_view', $comment, 'comment', $view_mode, $langcode);