Thumbnail image displayed in product list (summary) with projection layout (use shape layout) in module nwazet commerce

Topics: Customizing Orchard
Aug 6, 2013 at 4:29 AM
hi guys,
I use shape layout in projection, and i cannot get MediaUrl from product (summary). I use shape tracing but just get product image name, display name. I want display list product with thumbnail image and some info (etc carousel, slide ..v.v). any way?

Thank you.
Developer
Aug 6, 2013 at 5:27 AM
Edited Aug 6, 2013 at 5:27 AM
Can you tell a little bit more about the structure of your content type? For example, for the following structure:
Product (Content Type)
---ProductPart (Content Part)
------Image (MediaLibraryPickerField)
You could access the MediaUrl for the first selected media item like this:
var mediaPart = ((Orchard.MediaLibrary.Fields.MediaLibraryPickerField)content.ProductPart.Image).MediaParts.FirstOrDefault();
var url = mediaPart != null ? mediaPart.MediaUrl : default(string);
What's important to understand with the MediaLibraryPickerField is that it has a MediaParts property that contains 0 or more media items, so you want to be mindful about accessing that in your code.
Aug 6, 2013 at 7:13 AM
hi,
thank for reply.

Image from model :

image model


i use Nwazet module ecommerce, and use shape layout projection in orchard 1.7. But in model (summary) not media url. i have use placement.info but nothing happens.

P/S : placement.info working with default projection layout.

thanks again!
Coordinator
Aug 6, 2013 at 9:22 AM
Did you try what Sipke suggested?
Aug 6, 2013 at 3:00 PM
Hi sfmskywalker,BertrandLeRoy

thanks you very much. i have done. you save my life. Customers going to kill me. ))