I'm confused in how the fields can be rendered.
There are 2 variables in node.tpl.php $node
and $content
, both of which contain fields.
My task was to render all fields separately, to surround them with custom html. First I've tried
print render($content['field_service_summary'])
and got
array(1) { [0]=> array(1) { ["#markup"]=> string(11) "Engineering" } } Engineering
in result.
Trying to get rid of that array, I've taken another approach so the code became:
$field = field_get_items('node', $node, 'field_service_summary');
$output = field_view_value('node', $node, 'field_service_summary', $field[0]);
print render($output);
which actually worked, so, to clear this out I have following questions:
1) Where did that array come from when doing print render(content['field_service_engineering']);
and how can I get rid of it(I still like this rendering approach better cause it's just shorter) ?
2) Is the second method I've used totally good, with no drawbacks ?
3) What's the point in keeping fields info both in $content
and $node
especially regarding that in vanilla node.tpl.php only $content
is used for rendering fields ?
4) Just my curiosity: in $content
array every field has value #object which seems to contain the node object itself. What is it for ?