public ActionResult RelatedArticles() { /* make sure the datasource or current has children in the current language and render accordingly */ List <SimpleItem> items = new List <SimpleItem>(); //first get items related to me... MultilistField related = Sitecore.Context.Item.Fields["Prerequisite Articles"]; if (related != null) { foreach (Item i in related.GetItems()) { if (SiteConfiguration.DoesItemExistInCurrentLanguage(i)) { items.Add(new SimpleItem(i)); } } } //now get items I am related to foreach (Item i in Sitecore.Context.Database.SelectItems(SiteConfiguration.GetFurtherReadingArticlesQuery(Sitecore.Context.Item.ID.ToString()))) { if (SiteConfiguration.DoesItemExistInCurrentLanguage(i)) { items.Add(new SimpleItem(i)); } } // items.Sort(); // TODO: need to implement Comparer return(!items.IsNullOrEmpty() ? View(items) : ShowListIsEmptyPageEditorAlert()); }
private void Page_Load(object sender, EventArgs e) { List <Item> backgroundItems = new List <Item>(); List <Item> digDeeperItems = new List <Item>(); //first get items related to me... MultilistField related = Sitecore.Context.Item.Fields["Prerequisite Articles"]; if (related != null) { foreach (Item i in related.GetItems()) { if (SiteConfiguration.DoesItemExistInCurrentLanguage(i)) { backgroundItems.Add(i); } } } if (backgroundItems.Count > 0) { backgroundItems.Sort(new ItemSorterByTitle()); rptPrereq.DataSource = backgroundItems; rptPrereq.DataBind(); } //now get items I am related to foreach (Item i in Sitecore.Context.Database.SelectItems(SiteConfiguration.GetFurtherReadingArticlesQuery(Sitecore.Context.Item.ID.ToString()))) { if (SiteConfiguration.DoesItemExistInCurrentLanguage(i)) { digDeeperItems.Add(i); } } if (digDeeperItems.Count > 0) { digDeeperItems.Sort(new ItemSorterByTitle()); rptAdditional.DataSource = digDeeperItems; rptAdditional.DataBind(); } }