Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan 67 posts 146 karma points
    Oct 23, 2014 @ 08:39
    Nathan
    0

    Property Querying (archetype)

    Hi,

    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 textBox value based on the imgId parameter from the media picker, and to return a htmlString. Not sure if this the best ideea, I'm open to suggestions.

    public static string GetIcon(string iconId)
        {
            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 icon = Umbraco.TypedMedia(item.GetValue("img"));
        <img src="@icon.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
    

    Thanks,

    Dan

Please Sign in or register to post replies

Write your reply to:

Draft