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
Truly typed objects
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
Now in order to get IPhublishedContent, what you have to do is
is there any way we can modify the .generate file to get IList
Thanks
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.Thanks my friend. You saved my life :-)
is working on a reply...