MediaPicker field pb with Nwazet.Commerce

Topics: Customizing Orchard, General, Troubleshooting
Feb 4, 2013 at 12:02 PM
Edited Feb 4, 2013 at 12:31 PM
[Help Bertrand]
I have a custom content type using a mediapicker field.
After I installed Nwazet.commerce for evaluation, the Admin Content display of my custom type contents was disturbed, the image was displayed before my content.
I have not even created anything in the ecommerce module, just enabled it.
Setting a break point in the Render method of ShapeTemplateBindingStrategy, I realized that there was a BindingSource called named .....\Modules\Nwazet.Commerce\Views\MediaPickerProductImageSummaryAdmin.cshtml which was called to display the image field....
see Image
Any explanation welcome.

I am using a custom theme, here is my placement info
  <!-- Customize where the shapes are rendered -->
  <Match Path="~/">
    <Place Parts_Title="-"/>
    <Place Parts_Common_Metadata="-"/>
the placement info of my custom type, BSCarouselSlide, is here
    <Place Parts_BSCarouselSlide="Content:2"/>
    <Place Parts_BSCarouselSlide_Edit="Content:2"/>
  <Match DisplayType="SummaryAdmin">
    <Place Parts_BSCarouselSlide="Content:1;Alternate=Parts_BSCarouselSlide_SummaryAdmin"/>
    <Place Fields_MediaPicker="-"/>
    <Place Parts_Title="Content:1"/>
  <Match DisplayType="Summary">
    <Place Parts_BSCarouselSlide="Content:1;Alternate=Parts_BSCarouselSlide_Summary"/>
``` Last comment, my code is the last december v1.6.
Feb 4, 2013 at 3:59 PM
Edited Feb 4, 2013 at 4:01 PM
this method is NOK, for fields, it simply gets the last shape entered in the system without any regards to Contentype of the field which should have a priority in the search
Very fast but too fast. Looks like a bug.

        static bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding) {
            // shape alternates are optional, fully qualified binding names
            // the earliest added alternates have the lowest priority
            // the descriptor returned is based on the binding that is matched, so it may be an entirely
            // different descriptor if the alternate has a different base name
            foreach (var shapeAlternate in shapeAlternates.Reverse()) {
                if (shapeTable.Bindings.TryGetValue(shapeAlternate, out shapeBinding)) {
                    return true;
Feb 5, 2013 at 12:01 AM
Edited Feb 5, 2013 at 12:04 AM
After some Googlelizing I created a public class ShapeProvider : IShapeTableProvider
trying to be faster than Ecommerce Product.

Her I spent lot of time trying to understand the fact that when you ask Orcherd to add an alternate named according next line


it is because you have a file named fields.mediapicker-Image.summaryadmin.cshtml
do note the inversion between field name and displaytype ????

Is it due to this, I think it's a bug ?

It is a little dammage having to create code because the shape detection is not optimized to try its first match on the templates in the contentype where is the field......
Feb 5, 2013 at 1:32 PM
Edited Feb 5, 2013 at 1:36 PM
I just discovered that there are 2 versions of nwazet commerce.... bad... I just realized I updated the mercurial url and merged the 2 !!!!
I think the error I encountered was in the original part of code, but it seems that I was working on the ems version from december.....
I open a new thread for this.
Feb 10, 2013 at 8:01 AM
I'm totally confused by this. Is there a problem here I need to look at?
Feb 10, 2013 at 9:04 AM
I think that the MediaPickerProductImageSummaryAdmin.cshtml when installed by the ecommerce module is taking precedence on any contenttype using a medipickerfield and is used to render the mediapickerfield of any such contenttype. This for the display of Content in admin.
This was breaking my page with very large pictures where I was previously reducing the image size in this screen.
Feb 10, 2013 at 9:11 PM
OK, can you please create a bug on Bitbucket to track this and I'll look at it?