0
經過漫長的追問,終於得到了在node.tpl.php中將Drupal 7中的$ content分開的解決方案。
以前我使用了我使用:
print $node->field_name['und'][0]['value'];
這是給一個警告:
Notice: Undefined offset: 0 in include() (line 24 of C:\xampp\htdocs\drup\sites\all\themes\myCustomTheme\node.tpl.php)
現在我用下面這沒有錯誤正常工作的功能
$output= field_get_items('node', $node, 'field_name');
$output = $output[0]['safe_value'];
print $output;
現在的問題是我有超過50個字段在頁面上,我不認爲這將是有效的調用field_get_items('node',$ node,'field_name')函數50次。
什麼是備用? 或者我應該嚴格field_get_items函數 或者我應該嚴格打印$ node-> field_name ['und'] [0] ['value'];我聽說在Drupal 7中不好用,因爲und是未定義的。這雖然解決了我的問題,但給出了惱人的警告。