This project is read-only.

Is it possible to create a parent/child relationship between Content Types?

Nov 24, 2010 at 10:30 AM

If I have two content types Category (BodyPart, RoutePart) and Product (BodyPart, RoutePart)

1) Is it possible to create a relationship between Products and Categories without a custom module? Containable/Container?

1b) If not, what is the best way too solve this?

2) What is the recommended way of listing a content type (/products should list all Categories)? Widget?

3) How do I list all my products that match a specific category (/products/my-category should list all products and the category body)?

I'm currently using the latest default branch for my site.


Nov 24, 2010 at 1:40 PM

After fiddling a bit I'll try to answer some of my own questions.

1) Yes, using Containable and Container. The Content Types must have CommonPart.

2) The list is automatically populated when using above method.

3) Partially answered. The list is automatically populated when using above method, but the Category BodyPart is not rendered.


Is it a bug that the Categories BodyPart is not rendered or is this not supported?

Nov 24, 2010 at 6:46 PM

You should be able to write your own that does add it.

Nov 26, 2010 at 8:25 PM

According to 1.: Is it the best approach to implementing parent-child relationship in Orchard? I mean best in terms of "good-Orchard-practice" and performance.

I'm asking, because in Orchard.Roles there's an implementation of this kind of relation but it totally omits Container/Containable kind of stuff... I'm currently writing custom module adding newsletter functionality and I'm trying to figure out how to implement Newsletter/Recipients relation. There can be 100's to 1000's of recipients so performance is also an issue.

I'm using the latest dev branch.