1

I have a content type - question (its used for questions) AND content type - answer (it has a field -> nodereference to questions with select list)

How to display in a view block question title and below to each question - referenced node title of content type answer?

What i did: i'v created a view block, and filtering it by content type - question, now im displaying all question titles, but how to display answers below these question (Each answer below referenced question)

Something like:

Do you smoke cigarettes?

Yes, i do.

What's your name?

My name's Jack.

  • Are you using Drupal 6 or Drupal 7, and Views 2 or 3? The answer will be different depending on your versions. – Chapabu Dec 22 '11 at 14:51
  • Drupal 6.22 and Views version = "6.x-2.16" – Alexander Kim Dec 22 '11 at 14:57
4

You will have to create a relationship.

  1. Click the [+] next to Relationships in Views, and select the field that contains your node reference
  2. Make sure your Row Style is set to fields
  3. Select Node: Title - do not use the relationship yet.
  4. Next, select Node title again, but this time tell it to use the relationship (the field should be listed in your field listing as (Relatioship name) Node: Title).
  5. Filters should be set to whatever your content type for questions is called.
  • I should set 2 content types in node: type filter? Question and Answer, right? Because "answers" is not displaying below each question. – Alexander Kim Dec 22 '11 at 15:16
  • hmm..possibly..if it doesn't work the way I've described, try setting filter to Node:Type must be one of Question or Anwser Not got a D6 installation to hand so can't check atm =\ – Chapabu Dec 22 '11 at 15:19
  • I had to set node: type -> Answer, not for questions. Thanks :) – Alexander Kim Dec 22 '11 at 15:25
  • Interesting, i have 6 totally nodes: 3 question, 3 answer, and set to show 6 items in views, but it shows only 4, wtf? – Alexander Kim Dec 22 '11 at 15:57
  • Found the problem... When you post a question and that question doesn't have an answer - the question is not displaying without an answer... how to fix that? – Alexander Kim Dec 22 '11 at 18:15
1

You will need to add a views relationship for the node reference, then it will become available as a field.

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.