Copied to clipboard

Flag this post as spam?

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


  • Tahir 13 posts 73 karma points
    Feb 06, 2017 @ 16:43
    Tahir
    0

    Hi all,

    lets say you have a multiple media picker property called primaryHeaderItems. Now in Umbraco 7.4 and higher in generated file you have something like

    [ImplementPropertyType("primaryHeaderItems")]
            public string PrimaryHeaderItems
            {
                get { return this.GetPropertyValue<string>("primaryHeaderItems"); }
            }
    

    Now in order to get IPhublishedContent, what you have to do is

    private IList<IPublishedContent> GetContentItemsFromCsv(string csv)
            {
                var contents = new List<IPublishedContent>();
                var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    
                if (!string.IsNullOrWhiteSpace(csv))
                {
                    var listOfContents = csv.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
                    return umbracoHelper.TypedContent(listOfContents).ToList();
                }
                return contents;
            }
    

    is there any way we can modify the .generate file to get IList

    Thanks

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Feb 06, 2017 @ 16:45
    Kevin Jump
    100

    HI,

    if you also Core Property Value Converters package.

    https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters

    aAnd then generate your models you should get the property returning as a IEnumerable<IPublishedContent> collection.

  • Tahir 13 posts 73 karma points
    Feb 09, 2017 @ 16:33
    Tahir
    0

    Thanks my friend. You saved my life :-)

Please Sign in or register to post replies

Write your reply to:

Draft