2012-02-10 114 views
0

我正在學習Drupal 7計算領域。根據網絡資源他們說我應該使用$entity而不是$node Drupal 7.Drupal 7計算領域

我有一個內容類型的產品與自定義字段field_price和field_discount。我需要一個計算字段field_finalprice = field_price - field_discount

作爲第一步,我只是想分配field_discount我finalprice所以我創建了一個計算字段與代碼

$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_discount'))); 

我沒有得到任何價值。請提供使用計算字段爲Drupal 7

回答

1

有在評論中更新的任何鏈接IIRC http://drupal.org/node/1271050

$entity_field[0]['value'] = $entity-> field_price[LANGUAGE_NONE][0]['value'] - $entity-> field_price[LANGUAGE_NONE][0]['value'] 

應該工作