I want to do something which sounds very simple but apparently isnt, which is to include a link to a node (added using nodereference) in a view, using the name (title) of the referencing node s link text. However, neither using "content: field_node_reference" or "node: title" do I manage to do this. I only seem to be able to link using the referenced node as link text. Am I doing something wrong here? Is there any good resource/tutoria available to learn about view relationships (the screencasts arent very good imho)? Another option would be to get the ID from the referenced node, but there is no token for this either... I'm stuck. Could anyone help me out, please?

Comments

WorldFallz’s picture

You need to add a relationship using the nodereference field-- then you can access fields in either node (the current node or the referenced node).

You said you didn't think the screencasts were very good (i disagree, btw, but it all depends on which ones you're talking about), but have you seen the views relationsips one?

nutkenz’s picture

I did add a relationship: Link (field_node_reference)

But adding this relationship in "Defaults: Configure field Content: Link (field_node_reference)" does not change anything, there isn't any token to include the title of the Spotlight node...

Here is the query:

SELECT node.nid AS nid,
node_data_field_spotlight_image.field_spotlight_image_fid AS node_data_field_spotlight_image_field_spotlight_image_fid,
node_data_field_spotlight_image.field_spotlight_image_list AS node_data_field_spotlight_image_field_spotlight_image_list,
node_data_field_spotlight_image.field_spotlight_image_data AS node_data_field_spotlight_image_field_spotlight_image_data,
node.type AS node_type,
node.vid AS node_vid,
node_data_field_node_reference.field_node_reference_nid AS node_data_field_node_reference_field_node_reference_nid,
node_node_data_field_node_reference.nid AS node_node_data_field_node_reference_nid,
node_node_data_field_node_reference.type AS node_node_data_field_node_reference_type,
node_node_data_field_node_reference.vid AS node_node_data_field_node_reference_vid,
node_revisions.body AS node_revisions_body,
node_revisions.format AS node_revisions_format,
node_node_data_field_node_reference.title AS node_node_data_field_node_reference_title
FROM node node
LEFT JOIN content_type_spotlight node_data_field_node_reference ON node.vid = node_data_field_node_reference.vid
INNER JOIN node node_node_data_field_node_reference ON node_data_field_node_reference.field_node_reference_nid = node_node_data_field_node_reference.nid
LEFT JOIN content_type_spotlight node_data_field_spotlight_image ON node.vid = node_data_field_spotlight_image.vid
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE node.type in ('spotlight')

Regarding the screencasts, I'm just not very good at listening I suppose :) I prefer reading. Aren't there any written instruction guides on this subject?

WorldFallz’s picture

You won't get a token until you add the field-- you need to add a field (say "Node: title"), then select the relationship you created for the nodereference field to get the referenced node's field.

And no, I don't know of any written instructions-- the trend is increasingly toward screencasts. I had to watch the relationship video a couple of times, but it was worth it.