After reading the documentation and searching through code, I can't quite figure out what the entity_view function is for.
The documentation explains it executes the view callback if defined, with a fallback to the entity controller's view function. Since I use the EntityAPIController I want to use that view function, that adds a similar structure like below.
So I assumed entity_view is to replace a structure like this (part of a page callback).
// Prepare the entities
entity_prepare_view('entity_type', $entity_field_query_result);
// Apply theme to all entities
foreach($entity_field_query_result as $key => $item) {
$entity->content = array();
$entity->content += array(
'#theme' => 'my_entity_theme',
'#element' => $item,
'#view_mode' => 'full',
'#language' => LANGUAGE_NONE,
);
$render[$key] = $entity->content;
}
return $render;
Thus I've replaced that with
$render = entity_view('entity_type', $entity_field_query_result);
return $render;
This however shows an empty page, where the previous function showed me a list of entities. I have custom themes applied to these entities as follows, could that be an issue?
function my_module_theme($existing, $type, $theme, $path) {
return array(
'my_entity_theme' => array(
'variables' => array('element' => null),
'template' => 'my_entity_theme',
'path' => $path . '/template',
),
);
}
So, is my assumption on entity_view correct, or am I missing steps to come to a renderable output?