umbraco - Getting Media from code in repository -
i'm working in umbraco 7 , i'm trying map info custom entity have created. mapping strings, int ect. quite simple can tell me how can map content created media picker, multi media picker , content picker?
my simple model:
public class frontpage : master { public string headline { get; set; } public htmlstring content { get; set; } public string image { get; set; } public ienumerable<xxxx> images { get; set; } <-- class/type should place here (imedia mayby) public ienumerable<xxxx> links { get; set; } <-- class/type should place here (icontent mayby) public ienumerable<newsitem> news { get; set; } }
in repository have method:
public frontpage getfrontpage(ipublishedcontent content) { var imageobject = <-- how map image image picker here var imagesobject = <-- how map images multi media picker here var linksobject = <-- how map multiple links content picker here var model = new frontpage { headline = !string.isnullorempty(content.getpropertyvalue<string>("headline")) ? content.getpropertyvalue<string>("headline") : content.name, content = new htmlstring(content.getpropertyvalue<string>("content")), image = <-- , goes here, images = <-- , goes here, links = <-- , goes here, news = null }; homecoming model; }
i hope makes sence of guys/girls ;o)
i found able phone call typedmedia , typedcontent in repository this:
var helper = new umbracohelper(umbracocontext.current); var image = helper.typedmedia(content.getpropertyvalue("image")); var link = helper.typedcontent(content.getpropertyvalue("link"));
this way can want both media , content picker ;o)
umbraco umbraco7
No comments:
Post a Comment