RustBeard
RustBeard

Reputation: 79

How print field of another node

I know, that I can print a field from current node in template by e.g.

<?php print render($field['title_field']); ?>

but how I can print another nodes field?

Upvotes: 0

Views: 580

Answers (2)

Prashant Kanse
Prashant Kanse

Reputation: 772

In Drupal 7 with the help of entity concept you can print any field.

field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL)

Ref : https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_value/7

Upvotes: 0

MilanG
MilanG

Reputation: 7124

First get that node id somehow, then load whole node:

$node = node_load($nid);

Inside that $node object you'll have your field value. print_r or var_dump $node to see exact structure and how to approach your field value.

Upvotes: 2

Related Questions