/// <summary> /// get the featured more courses /// </summary> /// <param name="contentItem"></param> /// <param name="multilistFieldID"></param> /// <returns></returns> private List <CourseDetails> GetMoreCourses(Item contentItem, ID multilistFieldID) { List <CourseDetails> moreCourses = null; //get the list of items selected in the multilist field IList <Item> featuredItems = SitecoreUtility.GetSelectedItemsInMultilistField(contentItem, multilistFieldID); //check for each item if it is of valid template and active.If yes, then add it to the list if (featuredItems != null && featuredItems.Count > 0) { moreCourses = new List <CourseDetails>(); foreach (Item featuredItem in featuredItems) { if (featuredItem.TemplateID == References.Templates.CourseDetailsPage.ID) { CourseDetails courseDetailsItem = new CourseDetails(featuredItem); if (courseDetailsItem != null && courseDetailsItem.IsActive) { courseDetailsItem.Instructor = GetInstructor(courseDetailsItem.SelectedInstructorItemID); moreCourses.Add(courseDetailsItem); } } } } return(moreCourses); }
/// <summary> /// get the featured related posts /// </summary> /// <param name="contentItem"></param> /// <param name="multilistFieldID"></param> /// <returns></returns> private List <Blog> GetRelatedPosts(Item contentItem, ID multilistFieldID) { List <Blog> relatedPosts = null; //get the list of items selected in the multilist field IList <Item> featuredItems = SitecoreUtility.GetSelectedItemsInMultilistField(contentItem, multilistFieldID); //check for each item if it is of valid template and active.If yes, then add it to the list if (featuredItems != null && featuredItems.Count > 0) { relatedPosts = new List <Blog>(); foreach (Item featuredItem in featuredItems) { if (featuredItem.TemplateID == References.Templates.BlogPage.ID) { Blog blogItem = new Blog(featuredItem); if (blogItem != null && blogItem.IsActive) { relatedPosts.Add(blogItem); } } } } return(relatedPosts); }
/// <summary> /// get the featured timetable events /// </summary> /// <param name="contentItem"></param> /// <param name="multilistFieldID"></param> /// <returns></returns> private List <TimetableEvent> GetTimetableEvents(Item contentItem, ID multilistFieldID) { List <TimetableEvent> timetableEvents = null; //get the list of items selected in the multilist field IList <Item> featuredItems = SitecoreUtility.GetSelectedItemsInMultilistField(contentItem, multilistFieldID); //check for each item if it is of valid template and active.If yes, then add it to the list if (featuredItems != null && featuredItems.Count > 0) { timetableEvents = new List <TimetableEvent>(); foreach (Item featuredItem in featuredItems) { if (featuredItem.TemplateID == References.Templates.TimetableEvent.ID) { TimetableEvent timetableEventItem = new TimetableEvent(featuredItem); if (timetableEventItem != null && timetableEventItem.IsActive) { timetableEventItem.Instructor = GetInstructor(timetableEventItem.SelectedInstructorItemID); timetableEvents.Add(timetableEventItem); } } } } return(timetableEvents); }
// GET: Footer public ActionResult RenderFooter() { FooterSource viewModel = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.FooterSource.ID) { viewModel = new FooterSource(renderingDatasourceItem); if (viewModel.IsActive) { viewModel.Identity = new Identity(viewModel.IdentitySourceItem); //get the list of items selected in the multilist field IList <Item> featuredItems = SitecoreUtility.GetSelectedItemsInMultilistField(viewModel.InnerItem, References.Templates.FooterSource.Fields.SocialLinks); //check for each item if it is of valid template and active.If yes, then add it to the list if (featuredItems != null && featuredItems.Count > 0) { viewModel.SocialLinks = new List <FooterSocialLink>(); foreach (Item featuredItem in featuredItems) { if (featuredItem.TemplateID == References.Templates.FooterSocialLink.ID) { FooterSocialLink oblFeaturedItem = new FooterSocialLink(featuredItem); if (oblFeaturedItem != null && oblFeaturedItem.IsActive) { viewModel.SocialLinks.Add(oblFeaturedItem); } } } } } else { viewModel = null; } } } catch (System.Exception ex) { LogManager.SaveLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, ex, LogManager.LogTypes.Error, string.Empty); } return(View(GlobalConstants.SUBLAYOUTS_PATH + "PageContent/Footer.cshtml", viewModel)); }
public ActionResult RenderBannerCarousel() { BannerCarouselSource viewModel = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.BannerCarouselSource.ID) { viewModel = new BannerCarouselSource(renderingDatasourceItem); if (!viewModel.IsActive) { viewModel = null; } else { //get all the active carousel slide items selected in the multilist field List <Item> selectedItems = SitecoreUtility.GetSelectedItemsInMultilistField(renderingDatasourceItem, References.Templates.BannerCarouselSource.Fields.Slides) .Where(x => x.Fields[References.Templates.BannerCarouselSlide.Fields.IsActive].Value == "1").ToList(); if (selectedItems != null && selectedItems.Count > 0) { viewModel.Slides = new List <BannerCarouselSlide>(); foreach (Item item in selectedItems) { BannerCarouselSlide featuredItem = new BannerCarouselSlide(item); viewModel.Slides.Add(featuredItem); } } } } } catch (System.Exception ex) { LogManager.SaveLog(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, ex, LogManager.LogTypes.Error, string.Empty); } return(View(GlobalConstants.SUBLAYOUTS_PATH + "PageContent/BannerCarousel.cshtml", viewModel)); }