Programatically load and render a view mode

Including an access check.

$node = node_load($nid); // also possible: entity_load_single or entity_load
$view_mode = 'my_view_mode';
if(node_access('view', $node)){
  $entity_view = entity_view('node', array($node), 'my_view_mode');
  return render($entity_view);
} else {
  return FALSE;


This is the company blog of
Drupal specialist

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