我需要渲染字段集合中的单个字段,以便根据特定条件调整字段顺序,字段内容,删除包装DOM节点等。渲染单个FieldCollectionItemEntity字段
我一直在阅读this thread,因为它似乎是关于此问题的最佳资源,但我无法弄清楚为什么此字段集合渲染器不起作用。
它只是输出什么。
node--component-icon-promo.tpl.php
<? if (!empty($content['field_icon_promo_items'])) : ?>
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php foreach ($content['field_icon_promo_items']['#items'] as $entity_uri): ?>
<?php
$item = entity_load('field_collection_item', $entity_uri);
?>
<?php foreach ($item as $item_object): ?>
<?php print render($item_object->field_cta); ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
<? endif; ?>
添加权之前print render
dpm($item_object);
输出这一点。
而改变<?php print render($item_object->field_cta); ?>
到<?php print render($item_object); ?>
只是导致错误。
Recoverable fatal error: Object of class FieldCollectionItemEntity could not be converted to string in include() (line 99 of /var/www/html/sites/all/themes/xerox/templates/node--component-icon-promo.tpl.php).
我知道那是因为$ item_object就是这样,一个物体render doesn't like。 API的字段集合位似乎是一团糟。
任何帮助将不胜感激。
很喜欢我需要它这个代码没有工作,但metadata包装将我推向了正确的方向! – Hawxby