I have an Archetype property editor set up with multiple fieldsets, each fieldset with 2 fields: a text box, and a media picker for image.
In a GetImage(string imgId){}
method I'm trying to get the fieldset with the image url and text box value based on the imgId
parameter from the media picker, and to return a htmlString. Not sure if this the best idea, I'm open to suggestions.
public static string GetIcon(string imgId)
{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var myProperty = (IPublishedContent)umbracoHelper.Content(5369).GetPropertyValue<ArchetypeModel>("myProperty");
return "";
}
To get all the items from property I would do:
foreach (var item in myProperty)
{
var imgId = item.GetValue("img") //get the image id
var img = umbracoHelper.TypedMedia(imgId);
<img src="@img.Url" />
<span>@item.GetValue("imgTitle")</span>
}
I noticed while debugging that fieldsets within archetype property don't have built in unique ID's ???
How can I get the image and textBox value by comparing the image Id from media picker?
Something like: ??
var icon = myProperty.Where(x => x.icon == iconId); //wrong