2

I am on Drupal 7.

I have two content types. Content type 1 is called Bulletin and content type 2 is called Bulletin Text. I have a node reference field in Bulletin Text content type that allows me to link it to a certain Bulletin object.

Now, when my user is on a Bulletin Text node I want him/her to:

  1. see all the other texts associated with that same Bulletin on a block to the side of the page;
  2. remove the current Bulletin Text node from the list of bulletin texts, as it wouldn't make much sense, as the block would be something like "other texts from in this Bulletin".

Is there a pure Views solution for receiving the nodereference value from the current node being displayed on the page (passing that parameter into the Views block) and showing the list of nodes associated with it (also removing the current nid from the list), or do I have to play around with Contexts, Panels or custom code? What do you consider the best approach for me to solve this?

2 Answers 2

1

I can't give you the complete Views-based solution off the top of my head (although I think it must be possible) but the key to the solution is using 'Contextual filters' (they used to be called 'Arguments' in D6/Views2) and relationships.

Contextual filters are filters that take their value from the url, so you can narrow down the results to the current node currently. By adding a relationship for the node reference field, you can retrieve information from the nodes referenced by that field.

If I'm not mistaken, you can add a second contextual filter that makes use of the relationship, to exclude the current node from the related nodes.

Sorry this is not a complete how-to, but I hope it gets you started.

1
  • Thank you, marcvangend, the fact is that I have been playing with the contextual filters and relationships and cannot find a solution. My thought was that first I should grab the current NID from the URL. Then I would add a relationship that would link this contextual filter to the nodereference field, the way you have suggested. Last I configure my fields to read from that reference, but this doesn't work... I have also tried several combinations from this basic set and it does not work either... Commented Jun 24, 2011 at 13:29
1

There is an issue for this: http://drupal.org/node/1083902 it allows you to use a relationship in views to load the other end of the reference.

Together with the relationship and one contextual filter and "exclude" argument in the contextual filter you can do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.