0
Umbraco 7에서 작업 중이며 내가 만든 사용자 지정 엔터티에 데이터를 매핑하려고합니다. 매핑 문자열, intect. 아주 간단하지만 누군가 내가 Media picker, Multi Media picker 및 Content picker에서 만든 컨텐츠를 어떻게 맵핑 할 수 있는지 말해 줄 수 있습니까?저장소의 코드에서 미디어 가져 오기
내 간단한 모델 :; O)
Umbraco 7에서 작업 중이며 내가 만든 사용자 지정 엔터티에 데이터를 매핑하려고합니다. 매핑 문자열, intect. 아주 간단하지만 누군가 내가 Media picker, Multi Media picker 및 Content picker에서 만든 컨텐츠를 어떻게 맵핑 할 수 있는지 말해 줄 수 있습니까?저장소의 코드에서 미디어 가져 오기
내 간단한 모델 :; O)
I I이 당신의 어떤 남자/여자로 sence을 만드는 희망
public Frontpage GetFrontPage(IPublishedContent content)
{
var imageObject = <-- How do I map a image from image picker here
var imagesObject = <-- How do I map images from multi media picker here
var linksObject = <-- How do I map a multiple links from 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 = <-- And finally what goes here,
Images = <-- And finally what goes here,
Links = <-- And finally what goes here,
News = null
};
return 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; } <-- What class/type should I place here (IMedia mayby)
public IEnumerable<XXXX> Links { get; set; } <-- What class/type should I place here (IContent mayby)
public IEnumerable<NewsItem> News { get; set; }
}
나는이 방법이 다음과 같이 내 저장소에서 TypedMedia 및 TypedContent를 호출 할 수 있음을 발견했습니다.
var helper = new UmbracoHelper(UmbracoContext.Current);
var image = helper.TypedMedia(content.GetPropertyValue("image"));
var link = helper.TypedContent(content.GetPropertyValue("link"));
이렇게하면 미디어 및 콘텐츠 선택 도구 모두에서 원하는 것을 얻을 수 있습니다.)