1

I am a bit new to this, but I do have a programming background, and I have been working with Drupal for a while.

I am putting together a site for our Yoga Studio and I have a content type (scheduled class) that has a field (field scheduled_class) that is a node reference to a content type (class description). The Scheduled Class content type has as field for date which is used in a calendar, and there are multiple classes using the same class description.

I am trying to use a view to attach fields from the class description to the scheduled class content type and I cannot get it to work. I have been banging my head against the wall for months now.

                               --> fields
Scheduled class --> Class Type --> fields   
                               --> fields

I have not been able to get the contextual filter and relationship set up properly to allow this to work. I have tried every single combination I can think of. I am pretty sure the source of the problem is trying to get the right default value of the Class Type, but I am not sure.

  • Can I please ask you to re-title the question to be more specific? – Letharion Apr 20 '12 at 20:20
2

What I would do:

Enable the query preview under Views settings.

  1. Create a new View.
  2. Make sure "Title" is a selected field, and that the titles of both "Scheduled classes" and "Class type" is available in the list.
  3. Add a new relationship, pick the one representing your node-reference. Make it required.
  4. Change the title-fields configuration to select the newly added the relationship.
  5. You should now only have titles from "Class type".

From there on, you likely want to add a contextual filter on a nid so you can pick out "Class type" from a specific "Scheduled class".

I haven't used references in a while. If you get stuck already here, give the same thing a try with entity reference instead, just to see if it plays better together with Views.

Also see Learn Views with NodeOne, episode 11 is specifically about relationships.

1

I think this will help you.

  1. Make a content view.
  2. Add a filter for "Content:type" that shows only the node of the "scheduled class" content type.
  3. Add the relationship "Content: Field node reference."
  4. Add the field "Content:body" and use the above relationship while displaying.

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.