Hi Everyone,
Recently I'm about to use Drupal 6 to build a list view where it will show a list of questions and its corresponding answers.
I've set up a question content type and answer content type and I'm using a cck nodereference field in the answer content type to refer to the question node id that ties to the answer.
Now I'm having trouble building a list effects like the following:
Question 1: blah blah blah...
Answer 1: blah blah blah...
Answer 2: blah blah blah...
Answer 3: blah blah blah...
.....
Question 2: blah blah blah...
Answer 1: blah blah blah...
Answer 2: blah blah blah...
Answer 3: blah blah blah...
.....
Question 3: blah blah blah...
Answer 1: blah blah blah...
Answer 2: blah blah blah...
Answer 3: blah blah blah...
.....
....
Question 10: blah blah blah...
Answer 1: blah blah blah...
Answer 2: blah blah blah...
Answer 3: blah blah blah...
.....
It's more like the view when using the comments module except that this time it's done in nodes.
How should I do it using views?
I initially come up with an idea where I can use a view to grab list of answers of each questions and then do it 10 times using views_get_view and a for loop in php. But my concern is this way it will hit database 10 times since under the hood it's generating 10 sql statements.
What will be a better way to do it?
Thank you very much.
Best Regards,
Jim
Comments
Why not just let comments be
Why not just let comments be the "answers". Is there any major reason to implement answers as a separate content type?
Check this out, too: http://drupal.org/node/123379
2 content
2 content types:
-Question
--title:Question
-Answer
--title:Answer (text)
--field:Question Reference (node-reference)
1 view:
-Relationship: Content->question-reference
-Fields:
--Question Title (use relationship question-reference, link to node)
--Answer Title (link to node)
-Style Settings:
--Group-by Question Title
Just a little more detail please
Hi lefnire,
Can you give a little more detail on your reply above?
It sounds like exactly what I am looking for, but I'm still a little confused.
I'm building a writing assignments section on my website. I need to be able to post a writing assignment for all users to see. Then each user should be able to submit his assignment. I will then either reply to the user's submission, or edit his submission directly. Users should be able to see their own work, and my comments to them, but not be able to see each other's work.
Is your suggestion above the right way to go?
I've had a really hard time looking for ways to keep users comments private.
Thanks for any help you can offer.