I have one content type 'class' and I have another content type 'lesson' and I want to easily display all lessons that belong to a class on the view of a 'class.' Is this possible and if so, how?

2 Answers 2


I would take a look at the "Panels" module, which allows you to create custom pages that can display multiple Views displays in one page.


Alternatively, instead of creating multiple content types, consider utilizing taxonomy terms to differentiate your classes and lessons.

For instance, create a list of terms for a new vocabulary "Class", which differentiates the different types of class.

Then, for each of your "Lesson" content type nodes, apply the specific class taxonomy term which applies.

Finally, you can create a View which displays Lessons content nodes, and have it filter the results to those Lessons which are tagged with a specific "Class" taxonomy term.

  • Upvoted for the Panels answer.
    – Letharion
    Feb 21, 2012 at 7:19
  • 1
    I really don't like panels, but i do like the taxonomy terms. Thanks!
    – Mike
    Feb 24, 2012 at 0:44

Good question. This requires a trick which is not easy to discover unless you've seen it before!

I'm assuming your Lesson type has a 'node reference' linking each Lesson to its appropriate Class? If not, that's a good place to start.

(I'm going to refer to Drupal 6 here: If you're using D7, I think you need the 'Entity Reference' module, and some things may be different.)

Then, create a View which lists all the nodes of type Lesson that are also Published.

Add an argument, which links to the node reference field mentioned above. You should then be able to enter, say, '2' in the Preview box at the bottom of the view-editing screen and get just a list of all the lessons for the class represented by node 2.

As an aside, let's assume you'd like to have a separate page listing those. Create a page display for the view, give it a URL path (say 'classlessons') and then you can add the node number to the URL to get your page:


I think a different URL format is nicer, though, something that indicates this is class 2 that we're talking about, not lesson 2. If you set the path of the view to be 'class/%/lessons', then the argument is taken from the location of the % sign, ie:


Isn't that nice?

OK, now in your case, you want this to appear on the class page itself. Create another display for your view, but this time a Block display rather than a Page display. This will give you a block that you can include on the page, but it has a problem: blocks don't have URLs, so how can they have arguments? There's a way to deal with this.

In your block display, click on the argument, and you'll see a section called 'Action to take if argument is not present'. One option is 'Provide Default Argument', and you can select 'Node ID from URL'. This basically says, "I know this block doesn't have a URL, but I want to take the argument from the node id of the page that it's in".

Finally, add this block to the relevant pages - the easiest way is probably to do this by URL: if your class pages have consistent URLs you can choose 'Show only on the listed pages' and enter, for example,


If they don't have consistent pretty URLs, take a look at the Pathauto module.

This should, I think, do what you want. Note that the 'Node ID from URL' default argument thing will work even if the URL you use doesn't actually have the node id in it but has an equivalent alias:


The system knows which node is being referred to and substitutes the appropriate ID.

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.