DD4T/DD4T.Providers.DxaModelService/TridionPageProvider.cs
/// <summary>
/// Get all urls of published pages
/// </summary>
/// <param name="includeExtensions"></param>
/// <param name="pathStarts"></param>
/// <param name="publicationID"></param>
/// <returns></returns>
Get all urls of published pages
Get all urls of published pages
public string[] GetAllPublishedPageUrls(string[] includeExtensions, string[] pathStarts)
        {
            ItemTypeCriteria isPage = new ItemTypeCriteria(64);  
            PublicationCriteria currentPublication = new PublicationCriteria(PublicationId); 
            Criteria pageInPublication = CriteriaFactory.And(isPage, currentPublication);
            if (includeExtensions.Length > 0)
            {
                PageURLCriteria[] extensionsCriteria = new PageURLCriteria[includeExtensions.Length];
                int criteriaCount = 0;
                foreach (string pageExtension in includeExtensions)
                {
                    extensionsCriteria.SetValue(new PageURLCriteria("%" + pageExtension, Criteria.Like), criteriaCount);
                    criteriaCount++;
                }
                Criteria allExtensions = CriteriaFactory.Or(extensionsCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allExtensions);
            }
            if (pathStarts.Length > 0)
            {
                PageURLCriteria[] pathCriteria = new PageURLCriteria[pathStarts.Length];
                int criteriaCount = 0;
                foreach (string requiredPath in pathStarts)
                {
                    pathCriteria.SetValue(new PageURLCriteria(requiredPath + "%", Criteria.Like), criteriaCount);
                    criteriaCount++;
                }
                Criteria allPaths = CriteriaFactory.Or(pathCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allPaths);
            }
            Query findPages = new Query(pageInPublication);
            string[] pageUris = findPages.ExecuteQuery();
            List<string> pageUrls = new List<string>();
            foreach (string uri in pageUris)
            {
                TcmUri tcmUri = new TcmUri(uri);
                PageMetaFactory metaFactory = GetPageMetaFactory(tcmUri.PublicationId);
                IPageMeta currentMeta = metaFactory.GetMeta(uri);
                pageUrls.Add(currentMeta.UrlPath);
            }
            return pageUrls.ToArray();
        }
public string [ ] GetAllPublishedPageUrls ( string [ ] includeExtensions , string [ ] pathStarts ) { ItemTypeCriteria isPage = new ItemTypeCriteria ( 64 ) ; PublicationCriteria currentPublication = new PublicationCriteria ( PublicationId ) ; Criteria pageInPublication = CriteriaFactory . And ( isPage , currentPublication ) ; if ( includeExtensions . Length > 0 ) { PageURLCriteria [ ] extensionsCriteria = new PageURLCriteria [ includeExtensions . Length ] ; int criteriaCount = 0 ; foreach ( string pageExtension in includeExtensions ) { extensionsCriteria . SetValue ( new PageURLCriteria ( " " + pageExtension , Criteria . Like ) , criteriaCount ) ; criteriaCount ++ ; } Criteria allExtensions = CriteriaFactory . Or ( extensionsCriteria ) ; pageInPublication = CriteriaFactory . And ( pageInPublication , allExtensions ) ; } if ( pathStarts . Length > 0 ) { PageURLCriteria [ ] pathCriteria = new PageURLCriteria [ pathStarts . Length ] ; int criteriaCount = 0 ; foreach ( string requiredPath in pathStarts ) { pathCriteria . SetValue ( new PageURLCriteria ( requiredPath + " " , Criteria . Like ) , criteriaCount ) ; criteriaCount ++ ; } Criteria allPaths = CriteriaFactory . Or ( pathCriteria ) ; pageInPublication = CriteriaFactory . And ( pageInPublication , allPaths ) ; } Query findPages = new Query ( pageInPublication ) ; string [ ] pageUris = findPages . ExecuteQuery ( ) ; List < string > pageUrls = new List < string > ( ) ; foreach ( string uri in pageUris ) { TcmUri tcmUri = new TcmUri ( uri ) ; PageMetaFactory metaFactory = GetPageMetaFactory ( tcmUri . PublicationId ) ; IPageMeta currentMeta = metaFactory . GetMeta ( uri ) ; pageUrls . Add ( currentMeta . UrlPath ) ; } return pageUrls . ToArray ( ) ; }
Get all urls of published pages
Get all urls of published pages
// TODO There must be an enum of these somewhere //Todo: add logic to determine site on url // Need to get PageMeta data to find all the urls
None
includeExtensions
string[]
None
pathStarts
string[]
None
publicationID
None