模块更改drupal中的视图字段值

时间:2014-07-25 14:41:37

标签: php drupal drupal-7

我需要编写php代码来改变我的视图的字段值。我在主题下有一个php模板文件,代码如下:

$view = views_get_view_result("gallery");
$count = count($view);
if ($count>=1) {
  $ids = explode(",", $view[0]->nextag_items_tags);
  $tagword = "";
  foreach ($ids as $id) {
      $query = db_select('nextag_words', 'a');
      $query->fields('a', array('tagword'));
      $query->condition('a.id', $id, '=');
      $results = $query->execute()->fetchField();
      $tagword .= $results . ",";
  }
  $view[0]->nextag_words_tagword = $tagword; 
  //?????? My question is here
}

我的问题是如何将新字段值设置为drupal视图,以便显示更改?这让我困扰了很长时间......

谢谢大家的时间!

1 个答案:

答案 0 :(得分:0)

您是否只需要更改视野显示?使用预处理函数或视图挂钩,如hook_views_pre_render()