Allow Multiple Content Items

Topics: Customizing Orchard, Writing modules
Jul 22, 2014 at 4:41 AM
Edited Jul 22, 2014 at 4:43 AM
How can I add the "Allow multiple content items" option to a custom content part that I created?

I have created my content part module call "howtostep". The content part is just two string fields called image and instruction. The content part will be part of a content item called "How To" The content item must have 1 or more how to steps in it so I want to have N number of content parts.

What do I need to do to "Allow multiple content items"? Is there a sample somewhere?
Aug 13, 2014 at 4:05 PM
I think taxonomies and projections might work.
if not, you should write your own module.

Aug 21, 2014 at 5:01 AM
Edited Aug 21, 2014 at 5:02 AM
Thanks, I found Amba.ImagePowerTools by By Alexey V. Ryazhskikh which lets you select multiple images and lets you define custom property fields for each image. Nice Module.
Marked as answer by praktit on 8/20/2014 at 10:01 PM
Aug 22, 2014 at 4:03 AM
Edited Aug 22, 2014 at 4:04 AM
Did you know you that the MediaLibraryPickerField also allows you to select multiple media items? And because media items are content items, you can extend those items with parts and fields as well.
Aug 22, 2014 at 4:35 AM
Yes, I did. The problem is that I couldn't figure out how to add a description to each individual image that I selected. The MediaLibraryPickerField let me choose multiple images but I couldn't add a unique description to each image. Is there a way to do that with the MediaLibraryPickerField?
Aug 22, 2014 at 4:55 AM
Not through the MediaLibraryPickerField - that only allows you to browse for media items. But each media item itself can have a description. For example, you could add a TextField called "Description" to the MediaPart, which will cause all media items to have a Description field. Via the Media Library you can now specify a description for each image.
Aug 22, 2014 at 5:11 PM
Or you could use the Caption property already here, and you can also edit it while you are picking it, just click Edit on the media while you are selecting it.
Aug 23, 2014 at 4:17 AM
If I use the caption property or I add a description field wouldn't I be stuck with one distinct description per photo. How could the image be reused and have a different description when it gets added to a new content item? Plus I am trying to force users to add a description/instructions at the same time as when they add the photo to the content item.
Aug 23, 2014 at 1:29 PM
Then what you need if to add a custom field to the content type. You'll have a media field, and a text field for the description.

You could also create a custom part called MediaWithDescription and reuse it accross content types if necessary, but I don't think this is necessary here.