如何使用视图php创建一个链接来编辑视图中节点的特定字段值?

时间:2014-01-16 10:15:08

标签: php drupal drupal-views drupal-field-collection

我通过在我的视图显示中添加自定义php代码字段来使用视图php,因此我可以使用$data变量。在自定义PHP代码中,我正在渲染已添加了字段集合关系的字段:

<?php
global $user;
$html = array();

if (count($data->field_field_poi_link) > 0) $html[] = 'foobar';

if ($user->uid != 0 && arg(0) == 'node' && node_access('update', 'foobar', $user)) {
  $nid = arg(1);
  // $html[] = '<a class="inl_edit" href="'.$data->_entity_properties['url'].'/edit?destination=node/'.$nid.'">edit</a>';
  // $html[] = '<a class="inl_del" href="'.$data->_entity_properties['url'].'/delete?destination=node/'.$nid.'">delete</a>';
}
print join("\n",$html);

?>

在1月10日实体api更新之前,$data->_entity_properties数组包含此内容:

'_entity_properties' => 
  array (
    'url' => 'http://localhost:8888/project/field-collection/field-poi-link/39',
  ),

但现在,它没有包含这样的内容。我无法编辑那个特定条目。

如何在视图php字段中为每个字段集合输入的字段数据http://localhost:8888/project/field-collection/field-pois/74/edit创建一个特定值的链接?

1 个答案:

答案 0 :(得分:1)

如果你使用views hooks,也许会更好; 这比views_php更安全。 例如,您可以看到hook_views_pre_execute