public static Category GetCategoryByTitle(Publication objPublication, string categoryTitle) { Filter categoryFilter = new Filter(); categoryFilter.Conditions["Title"] = categoryTitle; // TODO: Refactor deprecated method GetCategories foreach (Category category in objPublication.GetCategories(categoryFilter)) { if (categoryTitle.ToUpper().Equals(category.Title.ToString().ToUpper())) { return(category); } } return(null); }
public override void Transform(Tridion.ContentManager.Templating.Engine engine, Tridion.ContentManager.Templating.Package package) { this.Initialize(engine, package); if (!this.IsPageTemplate()) { this.Logger.Warning("Calling Sitemap from a Component Template instead of a Page Template!"); return; } Publication publication = this.GetPublication(); _sitemap = new XmlDocument(); _sitemap.LoadXml("<siteMap xmlns=\"http://schemas.microsoft.com/AspNet/SiteMap-File-1.0\" />"); string baseUrl = publication.PublicationUrl.Substring(1); XmlElement navigation = CreateElement(_sitemap.DocumentElement, "navigation", "", "Navigation", ""); foreach (Category c in publication.GetCategories()) { if (c.Title == "Navigation") // TODO: make configurable in appSettings { foreach (Keyword kw in c.GetKeywords(new KeywordsFilter(Engine.GetSession()) { IsRoot = true })) { AddNodes(navigation, kw, c.Title, baseUrl); } break; } } XmlElement structure = CreateElement(_sitemap.DocumentElement, "structure", "", "Structure", ""); AddNodes(structure, publication.RootStructureGroup, baseUrl); this.CreateStringItem("Output", _sitemap.OuterXml, ContentType.Xml); }