Attaching parts to a Content Item

Topics: Customizing Orchard
Dec 8, 2014 at 6:23 AM
I want to implement a functionality to attach 'multiple instances of a part' to my 'content item' (not whole content type), e.g just like We can attach multiple instances of a field to a content type. Any idea in this regard?
Developer
Dec 8, 2014 at 6:56 AM
Content Items aren't designed to hold multiple content parts of the same type.
Dec 8, 2014 at 7:11 AM
Edited Dec 8, 2014 at 7:11 AM
@sfmskywalker! pardon me for being ignorant as I am new to Orchard, then how can I implement my functionality for multiple content parts of same type in content Item?

Should I use part as a widget, make a layer rule for specific content Item and add the widget to item then? (it will provide very partial case of what I need)
Should I play with Settings of my content part?

Throw me a rope to see in some direction please!
Developer
Dec 8, 2014 at 7:25 AM
No worries. Your initial post contains your answer - use content fields instead of content parts. To better advise you, I have a few questions of my own:
  • Why do you want to attach multiple instances of a part to your content item, and not to a content type?
  • Why do you want to attach multiple parts of the same type, instead of doing this with content fields, which are specifically designed for that purpose?
Dec 8, 2014 at 7:41 AM
Edited Dec 8, 2014 at 7:42 AM
  • Why do you want to attach multiple instances of a part to your content item, and not to a content type?
    I want to provide a single content type "Exam" with different functionalities (e.g it can have MCQs,True/False,Fill in blanks etc question genres combined as content parts). Now user can make a content Item from "Exam" and make a paper which can contain multiple MCQ,True/False sections as desired. That is why each Item,individually, should have functionality to attach multiple parts. Attaching them to content Type will make all Items same.
  • Why do you want to attach multiple parts of the same type, instead of doing this with content fields, which are specifically designed for that purpose?
    Because I think my MCQs,True/False,Fill in blanks are bigger entities and they should be implemented as parts rather than small fields.
Developer
Dec 8, 2014 at 1:26 PM
Aha. Sounds like you need to approach this slightly differently. Instead of attaching parts and fields to content items, consider writing a single ExamPart that provides the ability to contain questions of the various types you mentioned. A Question and Answer could be implemented as simple classes mapped to database tables.