You are here

function template_preprocess_views_view_row_comment in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 modules/comment.views.inc \template_preprocess_views_view_row_comment()
  2. 6.2 modules/comment.views.inc \template_preprocess_views_view_row_comment()

Template helper for theme_views_view_row_comment.

File

modules/comment.views.inc, line 694
Provide views data and handlers for comment.module.

Code

function template_preprocess_views_view_row_comment(&$vars) {
  $options = $vars['options'];
  $view =& $vars['view'];
  $plugin =& $view->style_plugin->row_plugin;
  $comment = $plugin->comments[$vars['row']->{$vars['field_alias']}];
  $node = $plugin->nodes[$comment->nid];

  // Put the view on the node so we can retrieve it in the preprocess.
  $node->view =& $view;
  $build = comment_view_multiple(array(
    $comment->cid => $comment,
  ), $node, $plugin->options['view_mode']);

  // If displaying the comments without links, remove them from the renderable
  // array; there is no way to avoid building them in the first place.
  // @see comment_build_content()
  if (empty($options['links'])) {
    foreach ($build as $cid => &$comment_build) {
      if (isset($comment_build['links'])) {
        unset($comment_build['links']);
      }
    }
  }
  $vars['comment'] = drupal_render($build);
}