Posted By

cphoover on 08/03/12


Tagged


Versions (?)

Get fields in a node.tpl.php


 / Published in: Other
 

  1. //USING THE FIELD API
  2.  
  3. $excerpt = field_get_items('node', $node, 'field_excerpt');
  4. $excerpt = field_view_value('node', $node, 'field_excerpt', $excerpt[0]);
  5.  
  6. $thumbnail = field_get_items('node', $node, 'field_page_thumbnail');
  7. //var_dump($thumbnail);
  8. $thumbnail = field_view_value('node', $node, 'field_page_thumbnail', $thumbnail[0]);
  9.  
  10.  
  11. //Or using the ENTITY API
  12.  
  13. //Method 1:
  14. //example of loading a field collection
  15.  
  16. $node_wrapper = entity_metadata_wrapper('node', $node);
  17. // the name of the field
  18. $featured_collection = $node_wrapper->field_featured_collection;

Report this snippet  

You need to login to post a comment.