This project is read-only.

Placement headaches in my module

Topics: Customizing Orchard, Writing modules
Aug 13, 2014 at 8:04 PM
I have a custom content part that is meant to be an image gallery. It has, right now, a gallery name (in the database) and a MediaLibraryPickerField. Here is the code from Migration.cs defining it:
                table => table
                .Column("GalleryName", DbType.String)

                typeof(ImageGalleryPart).Name, cfg => cfg.WithDescription("Image Gallery")
                    .WithField("Images", f => f
                        .WithSetting("MediaLibraryPickerFieldSettings.Hint", "Images to put in the image gallery.")
                        .WithSetting("MediaLibraryPickerFieldSettings.Required", "False")
                        .WithSetting("MediaLibraryPickerFieldSettings.Multiple", "True")
It's part of a content type that contains fields and data from a number of other parts. The problem I'm having is getting the two pieces of my ImageGalleryPart to render together when editing and when displaying.

They both render, but I'm not having any luck getting them to render together via placement. Here's my Placement file:
  <Match DisplayType="Detail">
    <Place Parts_ImageGallery="Content:5" />
  <Place Parts_ImageGallery_Edit="Content:5"/>
  <!-- Media Library Picker Field -->
  <Place Fields_MediaLibraryPicker_Edit="Content:5"/>
  <Place Fields_MediaLibraryPicker="Images:0"/>
Orchard finds my overriden view, and I am creating an ad-hoc zone to render the images to. Here's my view (minus the namespaces):
@model dynamic
    var imageGallery = (ImageGalleryPart)Model.Model;

<div style="width: 100%">
    <div style="float: left;">
        <div class="editor-field">
I can see that my view is being displayed and, sure enough, shape tracing is showing me that my ImageGalleryPart shape is rendering. But the MediaLibraryPickerField is rendering to the root Content shape and isn't behaving like it's part of my ImageGalleryPart shape.

It doesn't seem to recognize my Placement override and instead uses the from Orchard.MediaLibrary.

What am I missing?