N
N
NoMax2013-12-24 09:39:53
Drupal
NoMax, 2013-12-24 09:39:53

How to access a specific field of a Field Collection in Drupal 7?

Good afternoon.
I'm new to Drupal, small project - creating a theme for a project from scratch. I'm trying to figure out one thing:
I'm trying to themize a material node (! - not collections -!).
General node structure:

node:
--> title
--> content
--> field_item

Structure of field_item field collection:
field_item:
--> field_item_title
--> field_item_image
--> field_item_descr

I'm trying to access a field, for example field_item_title , which is contained in the Field Collection to display it in node.tpl.php
The collection consists of several fields (image, title, description). By design, I want to gut the first element of the collection and arrange its elements in the order I need, different from the field-collection-item.tpl.php template .
Output exactly according to the template, it was the first element of the collection that I did:
<? print render($content['field_item'][0]); ?>
But I need a specific field of the first element of the collection. How can you refer to it to display nodes in the template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2013-12-24
@andead

Working with fields in node.tpl.php is bad form. Themize the field template (template names are here - https://drupal.org/node/1089656#field-suggestion ).
You can get all the variables in a template with: debug(get_defined_vars());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question