2011-11-09 21 views
2

enter image description here試圖從數組值,Drupal的

我想從數組中值以下都嘗試

print $node->field_equiryform_custmessage[0][0]; 

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

我在做什麼錯?

由於

回答

3

在Drupal 7的字段陣列現在包裹着一個語言元素(在輸出的上述und裝置未定義,如在未定義語言)。

您可以訪問字段的值或者使用und作爲數組鍵或(最好)使用LANGUAGE_NONE常數:

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

如果你正在運行一個多語言系統,它看起來更像是這樣的:

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

後者可能實際上是這樣做的更具前景的方式。