as title

Comments

adrianmak’s picture

Just tried it support cck node reference.

Then,

I have a content type with a cck node reference field (allowed multiple values)
By default it output individual div for each value, now I want to use this module to output multiple values in unordered list.

By doing some debugging, the value stored is a nid, what is the snippet of php to get a node link with it's node title from a nid ?

aaron stanush’s picture

adrianmak, try the following:

$items = array();
foreach (element_children($element) as $key) {
  $items[] = l($element[$key]['#item']['safe']['title'], 'node/' . $element[$key]['#item']['safe']['nid']);
}
return implode(', ', $items);
deciphered’s picture

Status: Active » Fixed

Answer should be satisfactory.

Also, if more information is required from the referenced node, you would simply use node_load($nid) to load the node object (where $nid is the applicable node id).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pkej’s picture

Make sure to check the field "Handle multiple values" and to check that there actually are anything returned from the code; I had to do a numeric check on the nid to decide if I would return anything. There probably is a better way.