This following code snippet is the value of page callback from hook_menu(). However, I cannot connect entity_view and the page template. How can I print or access the entity_view returned in this code from my page template?

function example_task_view($task) {
  drupal_set_title(entity_label('example_task', $task));
  return entity_view('example_task', array(entity_id('example_task', $task) => $task), 'full');

1 Answer 1


You should pass the array of fully-loaded entity objects to the entity_view function, not only the id.

For example:

$entity = entity_load('example_task', array($task);
return entity_view('example_task', $entity, 'full');
  • How do I access that fully-loaded entity in the page template?
    – Randell
    Nov 19, 2013 at 7:50
  • If you look at the example code in my answer, you load the entity in the page callback function and return the view of it, which is a render array. The entity should already be printed on the page without any template. However, if you need to use your own template, i.e. override the page.tpl.php; you should be able to print it manually in the template like print render($page['content']); but I didn't test it.
    – Elin Y.
    Nov 19, 2013 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.