【问题标题】:Trying to get value from array, drupal试图从数组中获取价值,drupal
【发布时间】: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


    【解决方案1】:

    在 Drupal 7 中,字段数组现在用语言元素包装(上面输出中的 und 表示未定义,就像在未定义的语言中一样)。

    您可以使用und 作为数组键或(最好)使用LANGUAGE_NONE 常量来访问字段的值:

    print $node->field_equiryform_custmessage[LANGUAGE_NONE][0]['value'];
    

    如果您运行的是多语言系统,它看起来更像这样:

    print $node->field_equiryform_custmessage[$node->language][0]['value'];
    

    后者实际上可能是更面向未来的方式。

    【讨论】:

      猜你喜欢
      • 2016-05-29
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多