Example #1
0
        private bool ValidateNavigationKeywordsMetadata(Page page)
        {
            //If page is Index.aspx and it is in the root SG.
            if (page.OrganizationalItem.Title.Equals(publication.RootStructureGroup.Title) && GetPageName(page.PublishLocationUrl).ToLower().Equals(DefaultPage))
            {
                return(true);
            }

            bool result = false;

            //
            if (page.Metadata == null || page.MetadataSchema == null)
            {
                Logger.Info(string.Format("Page {0} removed from navigation, this page does not have metadata.", page.Title));
                return(result);
            }

            var meta   = new ItemFields(page.Metadata, page.MetadataSchema);
            var values = meta.Texts("NavigationKeywords");

            switch (_navigationType)
            {
            case NavigationTop:
                result = values.Contains(AddToTopNavigationKeyword);
                break;

            case NavigationBreadscrum:
                result = !values.Contains(RemoveFromBreadcrumbKeyword);
                break;
            }

            //For External PAges
            if (!result)
            {
                var externalUrl = meta.Text("ExternalUrl");
                result = !string.IsNullOrEmpty(externalUrl);
            }

            if (!result)
            {
                Logger.Info(string.Format("Page {0} excluded from {1} Navigation", page.PublishLocationUrl, _navigationType));
            }

            return(result);
        }