I have a nodereference field in a custom content type.
In Views: I want to be able to output a link like this:

The problem is that instead of outputting the nid of the referenced node, the [field_custom_noderef_nid] token is outputting the title of the referenced node...

Same applies to userreference module.

But maybe I'm missing something here... ?

#16 relationship-delta.JPG40.34 KBKimberley_p


adam1’s picture

I am struggeling with the same problem ...

markus_petrux’s picture

Category: task » support
Status: Active » Fixed

This is because Views is giving you the rendered output of the field in the replacement pattern.

To solve this, instead of using "Rewrite the output of this field" option of the field in Views, you need to provide a new formatter for nodereference fields, and then you can choose it from the "Format" option of the field in Views.

To create more formatters for noderef fields, see these examples:


Another approach: use a Views custom field - PHP code:


adam1’s picture

Thank you very much, markus. i will try out the alternatives.

Status: Fixed » Closed (fixed)

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

prabhakarsun’s picture

Easy way;

1. Add a relationship of required node reference.
2. Add a Node:Nid field with this relationship,rewrite it's output as you wish.

dag_helstad’s picture

@prabhakarsun: Thanks! I would *never* have figured out that by myself :)


m4olivei’s picture

@prabhakarsun: The only issue with your solution is when the node reference field can have multiple values. When you have multiple values, adding the relationship and adding the node id of the relationship will produce a row for every value of the node reference field. What then? This is where I find myself.

What I would like is to simply add the node reference field to my fields which would give me a list of the node id's referenced, which I ca then use and theme how ever I want in template files. Do I have to write a custom formatter in that case?


m4olivei’s picture


I figured out what to do in my situation. What I ended up doing was to set the formatter to 'Teaser' on the node reference in the view, and then used a template file for that node type to render it how I wanted it.


eheuvel’s picture

@prabhakarsun: Works like a charm, thanks.

johnnydarkko’s picture

@prabhakarsun: I would like to use your solution but for some reason the "Node" option is not available Groups selection field. Does anybody else have this problem?

Here's what I've done so far:
1. I clicked on the + sign on in the relationships section.
2. Opened the groups pull down but "Node" was not an option.
3. Kept Groups at "All" option, Node: NID is not listed.

Bartezz’s picture


Brilliant, thanx for sharing!

shrop’s picture

@prabhakarsun: Thanks much. Works great! Been banging my head over this one.

ErikU’s picture

Awesome and so simple!! Thx

devkinetic’s picture

@johnnydarkko and anyone else hitting this...

There is no 'node' in the relationship section. You find 'content' and then add the node reference field you are trying to use.

Then add node:nid to your fields and select that relationship from the dropdown on the field settings screen.

skyself’s picture

Thanks a lot for the explanation for us newbies.
The prabhakarsun's solution suddenly became obvious.

Kimberley_p’s picture

40.34 KB

@m4olivei I had the same issue as you - having a nodereference field with multiple values.

I got round it another way - just in case anyone else is stuck - that is useful only if you have 3 or 4 values, otherwise the view becomes a bit cumbersome:

I added the nodereference field as a relationship 4 times (or as many as the max number in your multiple values). Then you set the delta to 1 for the first relationship, 2 for the second and so on so that each relationship corresponds to each value (image attached). Then you need to add the node id field the same number of times and assign a relationship to each.

You get a row for each value this way.

sja1’s picture

Issue summary: View changes

Hey Kimberley, thanks for sharing! I wish I had seen this a couple hours ago.

I think you meant to say you get a column for each value, rather than a row.

In my case I want a comma separated list of nids. So I used your technique and then hid all but the last nid field from display. I then enabled the rewrite the output option on the last field and used a rewrite value like [nid_1],[nid_2],[nid_3].

I had been trying to get a combination of the reference_views and views_delimited_list modules working but that route dead-ended. Your solution is very simple and works perfectly.