0
votes

Here is my scenario...

Using Orchard CMS 1.7.1 I have created a custom Content Type named 'VistaImage' using the Orchard UI. This Content Type defines one field based on a Media Library Picker Field, this field is also named 'VistaImage'.

A Projection of groups of Vista Images are placed in the 'Featured' Zone as a Widget reference and works well.

Using the Shape Tracer on the resulting page(s), the shape hierarchy looks as follows:

Zone [Featured]
   Widget
      List
          Content                         Alt: Content-VistaImage
             Fields_MediaLibraryPicker    Alt: Fields.MediaLibraryPicker-VistaImage
                Media
                    Parts_Image_Summary

What I want to do is to provide alternative shapes from the Content shape downwards. This is easy enough for Content itself and for Fields_MediaLibraryPicker (as the Shape Tracer automatically provides applicable alternatives (as indicated above)).

My problem comes in providing alternatives for the Media and Parts_Image_Summary parts.

Looking at the documentation for Alternates on the Orchard web site, I thought that if I created a new shape in my Theme at at /Views/Parts/Image.Summary-VistaImage.cshtml this would get referenced, but it does not (though if I remove the '-VistaImage' the shape does get used, but this would, I believe change this shape for every Content Type, which is not what I want to do).

Any advice/direction on how I should approach this requirement would be apprciated.

Thanks.

1

1 Answers

1
votes

From personal experience, when you get that low level in the shapes, alternatives don't work very well, if at all. The only way I best deal with those scenarios is to choose the next applicable shape above it, and do an if statement to determine if its the content you want, in which case to remove the default shape display and implement your own hard-coded layout.

eg if the shape simplay says @display(Model.whatever) and you know that displays is garbage for you, look into the model.

For example, I had trouble creating a 4 leveled menu for bootstrap as it only typically deals with 2 levels, so i manipulated the lowest level shape. I.e:

if{Model.Items.Any()}{
   //code to generate another submenu for that menuItem
}

This may not even be the most correct way to address this, just the solution I found has worked.

So in your case I'd use VS debug and breakpoint where the mediafield picker is rendered, and find out if the model holds any information letting you know it's your VistaImage content.