1

I am currently using Views PHP module to use Field Global PHP to render view value, but I dont know how to read taxonomy field value and field collection value, did anyone know how to do it??

Beside, my field collection has three field, one is boolean and the other is taxonomy fields, did anyone also know how to extract the value??

1 Answer 1

0

To load your field collection item and then extract the values needed, you have to load a field collection item entity as following:

entities = entity_load('field_collection_item', array($item_id))

Where your item id is the id of the field collection. This will return an array of entities, with array_shift you can get the first element out of the array. This element will contain all 3 fields.

3
  • Thanks, I would like to ask is the item id mean the number $row->field_collection_item_name or the content nid??
    – home1985
    Commented Mar 4, 2015 at 7:18
  • It is the $row->field_collection_item_name['value'] I think
    – Robin
    Commented Mar 4, 2015 at 7:28
  • Thanks. There is nth show and I switch to use $data->field_field_collection_item_name['0']['raw']['value'] but it show recoverable fatal error. May be I do more research on get the id first~~
    – home1985
    Commented Mar 4, 2015 at 8:02

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.