Did this article resolve your question/issue?



API to get the pages directly and indirectly using a page template

« Go Back


TitleAPI to get the pages directly and indirectly using a page template
URL Nameapi-to-get-the-pages-directly-and-indirectly-using-a-page-template
Article Number000203539
EnvironmentProduct: Sitefinity
Version: 11.x, 12.x,13.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
A site has a page template, and many templates are built using the page template.
Each template has multiple pages across multiple sites. How to get all the pages associated to the page template  directly or indirectly(having a page template that inherits from the given template)?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
There is no out of the box approach for this. A custom code implementation is required for teh same.
Attached is a webform that takes the title of the page template and returns a Grid with page title and site that it belongs to upon button click.

Following is the code for the same:
protected void Submit_Click(object sender, EventArgs e)
            PageTemplate pageTemplate = pageManager.GetTemplates().Where(t => t.Title == PageTemplateTB.Text).FirstOrDefault();
            MultisiteContext multisiteContext = SystemManager.CurrentContext as MultisiteContext;
            var siteName = multisiteContext.GetSites().Where(x=>x.IsDefault).FirstOrDefault().Name;
            if (pageTemplate != null)

                foreach (var t in pagetemplates)
                this.PagesGrid.DataSource = pages.Select(x=> new PageItem { Title = x.NavigationNode.Title, Site=(x.NavigationNode.RootNode.Name== "FrontendSiteMap"?siteName: x.NavigationNode.RootNode.Name)});

        private void GetChildTemplates(PageTemplate template)
            var ct= pageManager.GetTemplates().Where(x => x.ParentTemplate == template);
            foreach (var t in ct)
                if (t.ChildTemplates.Count!=0)

        private void GetPagesOfPageTemplate(PageTemplate template)
            pages.AddRange(template.Pages().Where(p => p.Status == ContentLifecycleStatus.Live).ToList());

        class PageItem
            public string Title { get; set; }
            public string Site { get; set; }

Last Modified Date6/17/2021 2:20 PM
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.