Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. function computed_field_field_highest_compute(&$entity_field, $entity_type, $entity, $field, $instance, $langcode, $items) {
  2. $temps = field_get_items($entity_type, $entity, 'field_temp');
  3. if (count($temps)) {
  4. $max = $temps[0]['value'];
  5. foreach($temps as $temp) {
  6. $max = $temp['value'] > $max ? $temp['value'] : $max;
  7. }
  8. $entity_field[0]['value'] = $max;
  9. }
  10. }
  11.  
  12. function computed_field_field_lowest_compute(&$entity_field, $entity_type, $entity, $field, $instance, $langcode, $items) {
  13. $temps = field_get_items($entity_type, $entity, 'field_temp');
  14. if (count($temps)) {
  15. $min = $temps[0]['value'];
  16. foreach($temps as $temp) {
  17. $min = $temp['value'] < $min ? $temp['value'] : $min;
  18. }
  19. $entity_field[0]['value'] = $min;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement