Guest User

Untitled

a guest
Apr 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function getWords() {
  2. $query = new EntityFieldQuery();
  3. $query->entityCondition('entity_type', 'node', '=')
  4. ->propertyCondition('status', 1, '=')
  5. ->propertyCondition('type', 'wall_of_words', '=');
  6. $result = $query->execute();
  7. return node_load_multiple(array_keys($result['node']));
  8.  
  9. $query = new EntityFieldQuery();
  10. $query->entityCondition('entity_type', 'node', '=')
  11. ->propertyCondition('status', 1, '=')
  12. ->propertyCondition('type', 'wall_of_words', '=');
  13. $result = $query->execute();
  14.  
  15. $nodes = $result['node'];
  16.  
  17. // Get all fields attached to a given node type
  18. $fields = field_info_instances('node', 'wall_of_words');
  19.  
  20. // Get id of body field
  21. $field_id = $fields['body']['field_id'];
  22.  
  23. // Attach a field of selected id only to get value for it
  24. field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));
  25.  
  26. foreach ($nodes AS $nid => $node) {
  27. print $node->body['und']['value'];
  28. }
  29.  
  30. $result = db_select('node', 'n')
  31. ->fields('n', array('title', 'body'))
  32. ->condition('type', 'wall_of_words' ,'=')
  33. ->condition('status', 1 ,'=')
  34. ->execute()
  35. ->fetchAssoc();
Add Comment
Please, Sign In to add comment