【问题标题】:Drupal 7 Computed fieldDrupal 7 计算领域
【发布时间】:2012-02-10 14:56:56
【问题描述】:

我正在学习 Drupal 7 计算域。根据网络消息来源,他们说我应该在 Drupal 7 中使用 $entity 而不是 $node

我有一个包含自定义字段 field_price 和 field_discount 的内容类型产品。我需要一个计算字段field_finalprice = field_price - field_discount

作为第一步,我只是想将 field_discount 分配给我的最终价格,所以我用代码创建了一个计算字段

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

我没有得到任何价值。请提供任何使用 drupal 7 计算字段的链接。

【问题讨论】:

    标签: drupal-7 computed-field


    【解决方案1】:

    cmets IIRC http://drupal.org/node/1271050有更新

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

    应该工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多