In the code above there are three attempts at getting the reference to the MMP. The first one:
var imageList = thisSku.GetPropertyValue("productImages");
Results in an error saying "The value of parameter 'id' must be either a string or an integer". Fair enough, I obviously need to provide an ID to the Umbraco.Media(int) call.
The second one, which is an attempt to get an array of ID's from the MMP:
var imageList = thisSku.productImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
Results in an error saying "Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Split'" which is a bit worrying on the face it, given other forum posts alluding to .Any being missed on previous builds of V7.x.
The third one:
var imageList = thisSku.GetPropertyValue("productImages").Split(new string[] { "," },StringSplitOptions.RemoveEmptyEntries);
Fails siliently. The page is displayed with empty img tags.
I'm at a loss as to what to try next. Any advice would be appreciated.
I have the Umbraco Core Property Value Converters but I don't think I'm actually using it as I don't know how and finding documentation in here is a nightmare.
I read somewhere that these value converters can cause issues with existing written code? I'm on a very tight deadline so don't want to risk delays, hence nervousness. However, if what I read was incorrect, I'm all ears ;)
In this case it is because when you have the converters, they are doing the work to make it simpler for you. I have tried to provide detailed documentation and samples for them here, have you seen it before?
Yes, I vaguely remember seeing that top level page and thinking it's actually making it harder and that if I used it, it could cause me even more confusion when looking at various code examples on the web. I thought I'd remove it at the time, but I didn't so I guess I'm stuck with it now. I'll have to have a more in depth read.
Get image from a child node MultiMedia Picker
V7.2.1
Site
---Product List
------Product 1
---------Sku 1
---------Sku 2
------Product 2
---------Sku 1
---------Sku 2
I have the following code which is attempting to display the first image in the gallery in each Product's Sku page on the Product List page:-
In the code above there are three attempts at getting the reference to the MMP. The first one:
Results in an error saying "The value of parameter 'id' must be either a string or an integer". Fair enough, I obviously need to provide an ID to the Umbraco.Media(int) call.
The second one, which is an attempt to get an array of ID's from the MMP:
Results in an error saying "Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Split'" which is a bit worrying on the face it, given other forum posts alluding to .Any being missed on previous builds of V7.x.
The third one:
Fails siliently. The page is displayed with empty img tags.
I'm at a loss as to what to try next. Any advice would be appreciated.
Craig
Hi Craig,
Do you have my value converters package installed?
Jeavon
HI Jeavon
I have the Umbraco Core Property Value Converters but I don't think I'm actually using it as I don't know how and finding documentation in here is a nightmare.
I read somewhere that these value converters can cause issues with existing written code? I'm on a very tight deadline so don't want to risk delays, hence nervousness. However, if what I read was incorrect, I'm all ears ;)
Craig
Ok, if it's installed then it's converting, so there's no need to split.
Try simply this:
That worked! So I'd been trying too hard. But, as with a lot of Umbraco coding, how do you discover this stuff? I waste hours and hours :(
Thanks Jeavon.
In this case it is because when you have the converters, they are doing the work to make it simpler for you. I have tried to provide detailed documentation and samples for them here, have you seen it before?
Yes, I vaguely remember seeing that top level page and thinking it's actually making it harder and that if I used it, it could cause me even more confusion when looking at various code examples on the web. I thought I'd remove it at the time, but I didn't so I guess I'm stuck with it now. I'll have to have a more in depth read.
Thanks again.
Craig
is working on a reply...