Skip to main content
deleted 4 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

// Display Codecode (PHP).
$display_output = $entity_field_item['value'];

Note: I'm I am using Drupal 7.

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

Display Code (PHP)
$display_output = $entity_field_item['value'];

Note: I'm using Drupal 7

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

// Display code (PHP).
$display_output = $entity_field_item['value'];

I am using Drupal 7.

Tweeted twitter.com/StackDrupal/status/856169513401942016
Integrate comments from OPer
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

Thank you.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

Display Code (PHP)
$display_output = $entity_field_item['value'];

Note: I'm using Drupal 7

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

Thank you.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

Display Code (PHP)
$display_output = $entity_field_item['value'];

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

Display Code (PHP)
$display_output = $entity_field_item['value'];

Note: I'm using Drupal 7

Source Link

Using a computed field: How to extract a field value from a referenced node into field collection. (Multiple value)

I have written this code inside a computed field, which has given me as result, the referenced entity numbers how are saved in the field as an array.

I would like to know how to extract from the entity number a specific field, such as the title.

Thank you.

foreach ($entity->field_campos as $field) {
} 
foreach ($field as $index => $valores) {
$terminos[] = $valores['value'];
}
$item2 = field_collection_item_load_multiple($terminos, $reset = FALSE);
foreach ($item2 as $indice => $values) {
$entity_field[]['value'] = $values->field_nombre_2['und'][0]['target_id'];
}

Display Code (PHP)
$display_output = $entity_field_item['value'];