/// <summary> /// To check whether Sitecore Item have presentation settings /// </summary> /// <param name="item">Current Item</param> /// <returns>HasPresentation</returns> public bool DoesSitecoreItemHavePresentation(ISiteMapItem siteMapItem) { var glassMapperService = ServiceLocator.ServiceProvider.GetService <IGlassMapperService>(); var item = glassMapperService.GetItem <Item>(siteMapItem.Id); return(item.GetRenderingReferences("default") != null); }
private static XElement CreateSitemapNode(ISiteMapItem item) { var itemElement = new XElement(xmlns + Url); itemElement.Add(new XElement(xmlns + "loc", item.Url.ToLowerInvariant().ToFullyQualifiedUrl())); if (item.LastModified.HasValue) { itemElement.Add(new XElement(xmlns + "lastmod", CreateXmlDate(item.LastModified))); } if (item.ChangeFrequency.HasValue) { itemElement.Add(new XElement(xmlns + "changefreq", item.ChangeFrequency.Value.ToString().ToLowerInvariant())); } if (item.Priority.HasValue) { itemElement.Add(new XElement(xmlns + "priority", item.Priority.Value.ToString(CultureInfo.InvariantCulture))); } return(itemElement); }
private XElement CreateItemElement(ISiteMapItem item) { XElement itemXML = new XElement("url", new XElement("loc", item.Url.ToLower())); if (item.LastModified.HasValue) { itemXML.Add(new XElement("lastmod", item.LastModified.Value.ToString("dd-MM-yyyy"))); } if (item.ChangeFrequency.HasValue) { itemXML.Add(new XElement("changefreq", item.ChangeFrequency.Value.ToString().ToLower())); } if (item.Priority.HasValue) { itemXML.Add(new XElement("priority", item.Priority.Value.ToString(CultureInfo.InvariantCulture))); } return(itemXML); }
private static XElement CreateSitemapNode(ISiteMapItem item) { var itemElement = new XElement(xmlns + Url); itemElement.Add(new XElement(xmlns + "loc", item.Url.ToLowerInvariant().ToFullyQualifiedUrl())); if (item.LastModified.HasValue) itemElement.Add(new XElement(xmlns + "lastmod", CreateXmlDate(item.LastModified))); if (item.ChangeFrequency.HasValue) itemElement.Add(new XElement(xmlns + "changefreq", item.ChangeFrequency.Value.ToString().ToLowerInvariant())); if (item.Priority.HasValue) itemElement.Add(new XElement(xmlns + "priority", item.Priority.Value.ToString(CultureInfo.InvariantCulture))); return itemElement; }
private static XElement CreateItemElement(ISiteMapItem siteMapItem) { var element = new XElement(Xmlns + "url", new XElement(Xmlns + "loc", siteMapItem.Url.ToLowerInvariant())); if (siteMapItem.LastModified.HasValue) { element.Add(new XElement(Xmlns + "lastmod", siteMapItem.LastModified.Value.ToString("o"))); } if (siteMapItem.ChangeFrequency.HasValue) { element.Add(new XElement(Xmlns + "changefreq", siteMapItem.ChangeFrequency.Value.ToString().ToLower())); } if (siteMapItem.Priority.HasValue) { element.Add(new XElement(Xmlns + "priority", siteMapItem.Priority.Value.ToString("F1", CultureInfo.InvariantCulture))); } return(element); }
private XElement CreateItemElement(ISiteMapItem item) { var itemElement = new XElement(_xmlns + "url", new XElement(_xmlns + "loc", item.URL.ToLowerInvariant())); // all other elements are optional if (item.LastModified.HasValue) { itemElement.Add(new XElement(_xmlns + "lastmod", item.LastModified.Value.ToString("yyyy-MM-dd"))); } if (item.ChangeFrequency.HasValue) { itemElement.Add(new XElement(_xmlns + "changefreq", item.ChangeFrequency.Value.ToString().ToLower())); } if (item.Priority.HasValue) { itemElement.Add(new XElement(_xmlns + "priority", item.Priority.Value.ToString("F1", CultureInfo.InvariantCulture))); } return(itemElement); }
private List <ISiteMapItem> GetRecursiveFlattenedSiteMapItems(ISiteMapItem parentItem, List <ISiteMapItem> allPageItemsFlattened) { if (parentItem != null) { var filteredPages = parentItem.Children.Where(x => DoesSitecoreItemHavePresentation(x)); foreach (var item in filteredPages) { if (item.IncludeInSitemap) { allPageItemsFlattened.Add(item); } if (item.Children.Count() > 0) { GetRecursiveFlattenedSiteMapItems(item, allPageItemsFlattened); } } return(allPageItemsFlattened); } return(null); }
private static void WriteMenuItemJsonObject(JsonTextWriter jsonWriter, ISiteMapItem siteMapItem) { jsonWriter.WriteStartObject(); // id jsonWriter.WritePropertyName("id"); jsonWriter.WriteValue(siteMapItem.Id); // text jsonWriter.WritePropertyName("text"); jsonWriter.WriteValue(siteMapItem.Text); // iconCls jsonWriter.WritePropertyName("iconCls"); jsonWriter.WriteValue(siteMapItem.IconClassName); bool hasChildren = siteMapItem.Children != null && siteMapItem.Children.Count() > 0; if (siteMapItem.Type != SiteMapItemTypes.Separator && !hasChildren) { if (!string.IsNullOrEmpty(siteMapItem.ClientSideCommand)) { jsonWriter.WritePropertyName("clientSideCommand"); jsonWriter.WriteValue(WebUtility.EncodeJavaScriptString(siteMapItem.ClientSideCommand)); } if (!string.IsNullOrEmpty(siteMapItem.PageUrl)) { jsonWriter.WritePropertyName("url"); jsonWriter.WriteValue(siteMapItem.PageUrl); } } else if (siteMapItem.Type != SiteMapItemTypes.Separator && hasChildren) { // menu jsonWriter.WritePropertyName("menu"); WriteMenuJsonObject(jsonWriter, siteMapItem.Children); } jsonWriter.WriteEndObject(); }