Drupal - 抓取和循环 CCK Nodereference 字段的 NID
似乎无法弄清楚我如何获取节点引用字段的多个 nid。
$node->field_name[0]['nid'] 获取 cck 节点引用字段的节点 id。
然而,当该 cck 节点引用字段具有多个值时,我就会陷入困境!
我的 php 有点粗略,所以使用数组和循环是相当困难的!
这是我的代码:
<?php foreach ((array)$node->field_industry as $item) { ?>
<li><a href="../industry/company/<?php print --NODEID--?>"><?php print $item['view'] ?></a></li>
<?php } ?>
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 } ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非我遗漏了什么,否则以下内容应该有效
unless I am missing something, the following should work
据我所知,您无法在一个节点引用字段中添加多个引用...但是,我只需创建自己的文本字段(field_multireferences),在其中输入我的引用:12;43;65;21;...
现在...
$myArray =explode(';', $node->field_multireferences[0]['view']);
foreach($myArray 作为....)
...
当然,这不支持自动完成等。
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;...
now...
$myArray = explode(';', $node->field_multireferences[0]['view']);
foreach($myArray as....)
...
of course that wouldn't support auto completion etc.