Пример #1
0
        public string GetTitle(TridionSiteMapNode node)
        {
            string title = null;

            string pageUri = null;

            if (node.Attributes["type"].Equals("64"))
            {
                pageUri = node.Attributes["id"];
            }
            else
            {
                var landingPageNode = node.ChildNodes
                                      .Cast <TridionSiteMapNode>()
                                      .FirstOrDefault(tn => tn.Attributes["type"].Equals("64") && tn.Title.StartsWith("000 "));

                if (landingPageNode != null)
                {
                    pageUri = landingPageNode.Attributes["id"];
                }
            }

            if (!String.IsNullOrEmpty(pageUri))
            {
                IPage landingPage;
                if (pageFactory.TryGetPage(pageUri, out landingPage))
                {
                    var landingCp = landingPage.ComponentPresentations.FirstOrDefault();
                    if (landingCp != null)
                    {
                        var component = componentFactory.GetComponent(landingCp.Component.Id, landingCp.ComponentTemplate.Id);
                        title = component.Fields["Heading"].Value;
                    }
                }
            }

            if (String.IsNullOrEmpty(title))
            {
                title = node.Title.Remove(0, 4);
            }
            return(title);
        }