Drupal 7 load node comments render entity view mode

Here's a quick snippet to load all comments for a certain node (nid) and render them using a certain view mode:

 

$cids = comment_get_thread($entity, COMMENT_MODE_FLAT, 100);

if (is_array($cids)) {
  $entities = comment_load_multiple($cids);
}

if (isset($entities)) {
  $view = entity_view('comment', $entities, 'full');
}
print drupal_render($view);

About

This is the company blog of
Drupal specialist Merge.nl

We are located in Breda (Netherlands) and build websites using Drupal. More about us.

Content on this blog is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.

Creative Commons License

Recent Comments

Social