简体   繁体   English

Drupal-CCK节点参考字段的抓取和循环NID

[英]Drupal - Grabbing and Looping NID of CCK Nodereference field

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. $ node-> field_name [0] ['nid']选取cck节点参考字段的节点ID。

however when that cck node reference field has more than one value i get stuck! 但是,当那个cck节点引用字段具有多个值时,我会卡住!

my php is abit sketchy atm so working with arrays and loops is being quite difficult! 我的php有点粗略的atm,因此使用数组和循环是非常困难的!

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 } ?>

unless I am missing something, the following should work 除非我缺少任何东西,否则以下内容应该有效

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

as far as i know you can't add multiple references within one node reference field... however i would simply create my own textfield (field_multireferences) where i would type in my references: 12;43;65;21;... 据我所知,您不能在一个节点引用字段中添加多个引用...但是,我只是创建自己的文本字段(field_multireferences),在其中键入引用:12; 43; 65; 21; ...

now... 现在...

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

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

of course that wouldn't support auto completion etc. 当然不支持自动完成等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM