"Course"라는 부분 이름을 추가 한 컨텐츠 유형 "Club"을 만들었습니다. 내 컨트롤러 코드에 Club (콘텐츠 유형) 목록을 가져오고 싶습니다.과수원 CMS의 컨텐츠 유형으로 필터링
당신은 당신의 컨트롤러 IContentManager에 접근 할 필요가public ActionResult Index(PagerParameters pagerParameters, CourseSearchVM search)
{
//this is displaying only published content
var courseQuery = _contentManager.Query<CoursePart>().List().ToList();
// Project the query into a list of customer shapes
var coursesProjection = from course in courseQuery
select Shape.course
(
Id: course.Id,
Name: course.Name,
Description: course.Description
);
// The pager is used to apply paging on the query and to create a PagerShape
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);
// Apply paging
var coures = coursesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize);
// Construct a Pager shape
var pagerShape = Shape.Pager(pager).TotalItemCount(courseQuery.Count());
// Create the viewmodel
var model = new CourseIndexVM(coures, search, pagerShape);
return View(model);
}
나는 위의 해결책을 시도했지만 내용 유형에 대한 기록을 가져 오지 않습니다. 작동중인 원래 게시물을 수정했지만 문제는 콘텐츠 형식 대신 콘텐츠 부분을 지정해야한다는 것입니다. 내 콘텐츠 유형이 "코스"이고 콘텐츠 콘텐츠 부분이 "코스" –
ForType ("코스")을 지정해야합니다. BTW에서는 course.ContentItem을 입력하기 만하면 ContentTypes에 액세스 할 수 있습니다. 그러나 각 파트의 전체 모양을 만들려면 ContentItem을 허용하는 BuildDisplay 메서드를 호출해야합니다. – jmgomez