0

gunwinner 是我的主题名称,我想更改特定内容类型的字段。我试过这段代码,

function gunwinner_preprocess_field(&$variables) {
  $element = $variables['element'];
  if($element['#field_name'] == 'field_deal_url') {
     $values = $element['#items'][0]['value'];
     $deal_link = l(t("Go to Store"), "$values", array('attributes' => array('class' => 'store-link')));
     $element['#items'][0]['value'] = "Store";
  return;
  }
}

它返回给我链接标题为“Go to Store”的数组,但它不会反映在特定字段的页面上。

谁能帮我解决这个问题?

4

1 回答 1

1

您正在制作副本$variables['element']并对其进行操作,因此更改不会保留到原始变量中。

只需将函数的第一行更改为

$element = &$variables['element'];
于 2013-03-30T12:42:22.603 回答