0

I need to build out a site that features courses and lessons, each defined as a content type. I currently have the site running with lessons linked to courses using entity reference (entity reference field is in lessons) and use EVA to attach a view of lessons to each course. (see screen below for reference)

This works fine, however I now have a new requirement to allow lessons to be re-used across multiple courses. This means:

  1. Courses can contain multiple lessons
  2. Lessons can appear in more than one course
  3. Lessons appear in "sections" which are custom per course
  4. Lesson and section sort order is custom per course
  5. Courses need to be able to handle up about 150 lessons per course

Since lessons need to appear in sections, the link requires both a reference and a section. I've experimented building this out with field collections embedded in the course entity. This works pretty well, but performance degrades significantly after about 30 lessons are added to a course.

To avoid the performance problem, another approach I'm considering is to code a compound field (entity reference with a text field) that would be added as an unlimited value field to the course content type.

Before I try the compound field approach, I'm seeking input/advice on the architecture for this solution. Given the requirements, and available D7 functionality, what approach makes most sense?

an example of a course with lessons

3
  • Does the required output, say when viewing a course, need to group the lesson by section? Do you need to customize the order of sections per course and the order of lessons within each section per course?
    – Jason
    Commented Jan 10, 2014 at 16:33
  • This sort of scenario reminds me of drupal.org/project/relation, which I've never tried, but always wanted to!
    – Jason
    Commented Jan 10, 2014 at 16:34
  • Yes, that's right. Lessons need to be grouped by section and the sort order needs to be custom by course. Re Relation: yes :) I've looked that project several times but not used it. I think one problem with relation might actually be sorting (drupal.org/node/1304196)
    – Dave Bruns
    Commented Jan 10, 2014 at 17:31

1 Answer 1

0

How about this unproven setup.

Create a third content type, Sections. Courses reference sections with a mutli-value entity reference field, which you can drag/drop the order of this field from the node edit form. You can use inline entity form to assist with content creation.

Then, reference Lessons from Sections with a multi-value entity reference field, also allowing you to drag/drop the order of the field values. Not sure if you can use the inline entity form within an inline entity form...maybe.

Then, you can continue to use EVA on both the courses and sections to display view results, using a node id contextual filter...I assume.

Or, you could just render the referenced entity, selecting a custom display mode, which you theme accordingly. This may offer better performance.

1
  • Yeah, I've been thinking about that idea too, but I've hesitated because it seems overly complex. I think I'll try the compound field idea first, then come back to sections-as-content-type idea if it doesn't seem to work well. It's funny, Drupal has a lot of functionality around entities these days, but this use case seems hard to support in a way that results in good performance and a good user experience.
    – Dave Bruns
    Commented Jan 12, 2014 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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