public ActionResult RenderBanner() { Banner banner = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.Banner.ID) { banner = new Banner(renderingDatasourceItem); if (!banner.IsActive) { banner = 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/Banner.cshtml", banner)); }
public ActionResult RenderPopularPosts() { PopularPostsSource viewModel = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.PopularPostsSource.ID) { viewModel = new PopularPostsSource(renderingDatasourceItem); if (!viewModel.IsActive) { viewModel = null; } else { viewModel.FeaturedBlogs = GetRelatedPosts(renderingDatasourceItem, References.Templates.PopularPostsSource.Fields.FeaturedBlogs); } } } 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/PopularPosts.cshtml", viewModel)); }
// 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 RenderCourseTeasersCarousel() { CourseTeasersCarouselSource viewModel = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.CourseTeasersCarouselSource.ID) { viewModel = new CourseTeasersCarouselSource(renderingDatasourceItem); if (viewModel.IsActive) { Item courseArchivePageItem = SitecoreUtility.GetItem(new ID(viewModel.CourseArchivePageID)); if (courseArchivePageItem != null) { //get all the active course items List <Item> coursePageItems = SitecoreUtility.GetItemsByTemplate(courseArchivePageItem, References.Templates.CourseDetailsPage.ID) .Where(x => x.Fields[References.Templates.CourseDetails.Fields.IsActive].Value == "1").ToList(); if (coursePageItems != null && coursePageItems.Count > 0) { viewModel.CourseTeasers = new List <CourseDetails>(); foreach (Item item in coursePageItems) { CourseDetails courseDetails = new CourseDetails(item); courseDetails.Instructor = GetInstructor(courseDetails.SelectedInstructorItemID); viewModel.CourseTeasers.Add(courseDetails); } } } } 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/CourseTeasersCarousel.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)); }
public ActionResult RenderTopMenu() { TopMenuSource topMenuSource = null; try { //get the datasource item assigned to the rendering Item renderingDatasourceItem = SitecoreUtility.GetRenderingDatasourceItem(); if (renderingDatasourceItem != null && renderingDatasourceItem.TemplateID == References.Templates.TopMenuSource.ID && renderingDatasourceItem.HasChildren) { topMenuSource = new TopMenuSource(renderingDatasourceItem); if (topMenuSource != null) { if (topMenuSource.IdentitySourceItem != null) { topMenuSource.Identity = new Identity(topMenuSource.IdentitySourceItem); } topMenuSource.TopMenuItems = new List <NavigationItem>(); //loop through all the child items and add active menu items to the list foreach (Item menuItem in renderingDatasourceItem.Children) { if (menuItem.TemplateID == References.Templates.NavigationItem.ID) { NavigationItem topMenuItem = new NavigationItem(menuItem); if (topMenuItem.IsActive) { if (menuItem.HasChildren) { topMenuItem.SubmenuItems = new List <NavigationItem>(); //loop through all the sub items of the menu item and add active items to its subitem list foreach (Item submenuItem in menuItem.Children) { if (submenuItem.TemplateID == References.Templates.NavigationItem.ID) { NavigationItem smItem = new NavigationItem(submenuItem); if (smItem.IsActive) { topMenuItem.SubmenuItems.Add(smItem); } } } } topMenuSource.TopMenuItems.Add(topMenuItem); } } } } } } catch (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 + "Navigation/TopMenu.cshtml", topMenuSource)); }