public Models.GlobalHeader GetGlobalHeader(RenderingContext renderingContext, Item contextItem) { var model = new Models.GlobalHeader(GetDatasource(renderingContext, contextItem, Global_Header_Constants.TemplateId)); // the GetDatasource returned no Sitecore item or it returned an item of the wrong template if (model.SitecoreItem == null || !model.SitecoreItem.IsOrInherits(Global_Header_Constants.TemplateId)) { var site = SiteFactory.GetSite(); if (site != null) { model.SitecoreItem = site.GetDefaultGlobalHeader(); } } if (model.SitecoreItem != null) { model.NavigationLinks = model.SitecoreItem.Children.Where(i => i.IsOrInherits(_Navigation_Link_Constants.TemplateId)); } return(model); }
private void ShowBrowser(string addressName) { var site = _siteFactory.GetSite(addressName); if (site == null) { return; } var addressWithoutPrefix = site.Address; if (String.IsNullOrEmpty(addressWithoutPrefix)) { return; } MyListBox.Visibility = Visibility.Collapsed; MyBrowser.Visibility = Visibility.Visible; var address = HelperFunctions.AddAddressPrefix(addressWithoutPrefix); MyBrowser.Navigate(address); HelperFunctions.TrySetSuppressScriptErrors(MyBrowser, true); }
private List <Item> GetResults(string q, string databaseName) { if (q.IsNotNullAndNotWhiteSpace()) { using (var searcher = ContentSearchManager.GetIndex(string.Format("sitecore_{0}_index", databaseName)).CreateSearchContext()) { var site = SiteFactory.GetSite(); return(searcher .GetQueryable <SearchResultItem>() .Where(i => i.Paths.Contains(site.SitecoreItem.ID) && i.Content == q) .ToList() .Select(i => i.GetItem()) .ToList()); } } else { return(new List <Item>()); } }