views:

347

answers:

1

Hello,

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

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.

n00b
I currently have a content type called industry and a content type called company. company holds a cck field called industry which is a Node reference type. the widget type is a select list in which you can select upto 6 values.i currently have the company node printing out the relevant data. when it gets to industry it displays ALL values selected with a link to its original node. what i need is that specific NID to use it to link the industry text elsewhere.
GaxZE