I have a custom content type A that has a field for node id which refers to a different content type B. While creating my view for content type A, I want to identify the id in the field entered by the admin and based on the id find out what node of content type B is being referred to and generate a teaser view for B in the View of A. Does anyone have any insight on how to do this? Its more like providing a list of References with links to an Article where Article and References are both different content types.


This is exactly what the node references field modules do. For example in your Article content type, you would create a new field 'Related to References' as a node reference field and link it to relevant nodes of the References content type. The field stores the title of the referenced node and its NID which makes it a lot more user-friendly interface than using a nid.

If you're using Drupal 7.x, the current recommendation is to use the Entity Reference module which takes over from the Node Reference module in CCK.

If you're using Drupal 6.x., you want to enable the Node Reference field which is part of the CCK module. This still leaves a migration path to 7.x by upgrading to the 'References' field module, and then migrating your reference fields to Entity Reference fields.

  • does this work for Drupal 7 as well? Or is there any other module that I should look at? – dshah Apr 24 '12 at 18:38
  • @drupal There are a few: References, Entity Reference and Relation. – Clive Apr 24 '12 at 18:39
  • sorry - hit return before got the links in but Clive's list is right on. If you're starting from scratch, you definitely want to use the Entity Reference module in 7.x because the other modules are losing support / maintainers in favor of the Relations API. – schnippy Apr 24 '12 at 18:44
  • thanks a lot for your response. I see an Autocomplete text field. What if I just want to reference based on a node id or some inherent id field that I am maintaining to refer to each of the References? How do I handle that? – dshah Apr 24 '12 at 18:56
  • its usually better UX to use the title of the referred node in your edits rather than a simple node id as subsequent editors will be able to tell at a glance what the referring node is without having to do a lookup on the node, etc. the node relationships modules we have proposed all operate on this principle and don't let you restrict to a particular field -- you would have to extend autocomplete for this field to add it into the autocomplete suggestions. – schnippy Apr 24 '12 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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