1

cant seem to work out how i grab multiple nids of a node reference field.

$node->field_name[0]['nid'] picks up the node id of the cck node reference field.

however when that cck node reference field has more than one value i get stuck!

my php is abit sketchy atm so working with arrays and loops is being quite difficult!

here is my code:

<?php foreach ((array)$node->field_industry as $item) { ?>
  <li><a href="../industry/company/<?php print --NODEID--?>"><?php print  $item['view'] ?></a></li>
<?php } ?>
4

2 回答 2

1

除非我遗漏了某些东西,否则以下内容应该有效

<?php foreach ($node->field_industry as $item) { ?>
  <li><a href="../industry/company/<?php print $item['nid']?>"><?php print  $item['view'] ?></a></li>
<?php } ?>
于 2011-02-23T14:01:42.193 回答
0

据我所知,您不能在一个节点引用字段中添加多个引用...但是我会简单地创建自己的文本字段 (field_multireferences),在其中输入我的引用:12;43;65;21;...

现在...

$myArray = explode(';', $node->field_multireferences[0]['view']);

foreach($myArray as....) ...

当然不支持自动完成等。

于 2010-03-19T12:40:51.793 回答