【发布时间】:2011-11-09 20:53:04
【问题描述】:
我正在尝试从下面的数组中获取值
print $node->field_equiryform_custmessage[0][0];
和
print $node->field_equiryform_custmessage[0]['value'];
我做错了什么?
谢谢
【问题讨论】:
标签: php arrays templates drupal drupal-7
我正在尝试从下面的数组中获取值
print $node->field_equiryform_custmessage[0][0];
和
print $node->field_equiryform_custmessage[0]['value'];
我做错了什么?
谢谢
【问题讨论】:
标签: php arrays templates drupal drupal-7
在 Drupal 7 中,字段数组现在用语言元素包装(上面输出中的 und 表示未定义,就像在未定义的语言中一样)。
您可以使用und 作为数组键或(最好)使用LANGUAGE_NONE 常量来访问字段的值:
print $node->field_equiryform_custmessage[LANGUAGE_NONE][0]['value'];
如果您运行的是多语言系统,它看起来更像这样:
print $node->field_equiryform_custmessage[$node->language][0]['value'];
后者实际上可能是更面向未来的方式。
【讨论】: