dony113407 2015-09-11 19:59
浏览 69
已采纳

Drupal查看php字段集合值

I am using Drupal 7.

In a node, I have a field collection, and in that field collection I have a field called 'amount' which is an integer field.

When I try to display this value within a view column using 'Views PHP' module, in the available variables it appears as

$row->field_amount: Field collection item: amount

However when I print/echo this, the value that appears is not correct. It seems to show the ID of the field collection or so.

On extra note, the view is a taxonomy view. It is deriving the field collection field using a relationship to the node.

How can I get it to show the actual value inserted in views php?

  • 写回答

1条回答 默认 最新

  • dongyao8698 2015-09-15 13:10
    关注

    That is a common "bug" of the Views PHP module... you'll only get the nid of the node!

    if this is not a high-traffic/performance site, i recommend you to load the node in the view field and access the value via the node-variable..

    for example:

    <?php
        $node = node_load($row->field_amount);
        echo $node->field_amount['und'][0]['value'];
    ?>
    

    that code is not tested, but i hope, you get the idea...

    if you are not sure, how to access the data, you definitely should install the devel module... with devel, you can nicely print out the variable like:

    <?php
        dpm($node);
    ?>
    

    and find the right value...

    as far as i know, there is no other way with the Vies PHP module... sorry

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?