Query all pages of a translation

Native API

To get all pages in a particular language, you use the GetPageDataList method. Then, you filter based on the Culture property, the LocalizationStrategy, theNodeType, and theRootNodeId. As a result, you get all pages for the specified language.

Use the following code sample:

C#
using System.Linq;
using System.Threading;
using Telerik.Sitefinity.Modules.Pages;

namespace SitefinityWebApp
{
    public class QueryPages_GetAllTranslationsOfPage_NativeAPI
    {
        public void GetAllTranslationsOfPage()
        {
            var cultureInfo = new System.Globalization.CultureInfo("cz");
            var currentCulture = Thread.CurrentThread.CurrentUICulture;
            var ci = System.Globalization.CultureInfo.GetCultureInfo("cz");
            var pageManager = PageManager.GetManager();
            var pages = pageManager.GetPageDataList().Where(pageData =>
                (pageData.Culture == "cz" ||
                pageData.NavigationNode.LocalizationStrategy != Telerik.Sitefinity.Localization.LocalizationStrategy.Split) &&
                pageData.NavigationNode.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Standard &&
                pageData.NavigationNode.RootNodeId == Telerik.Sitefinity.Abstractions.SiteInitializer.CurrentFrontendRootNodeId)
            .Select(x => x.NavigationNode);
            var filteredTranslations = pages.ToList();
        }

    }
}

Fluent API

To get all live pages, you use the plural facade to get all page nodes. Then, you filter based on the NodeType property and the PageData object.

Use the following code sample:

C#
using System.Globalization;
using Telerik.Sitefinity;

namespace SitefinityWebApp
{
    public class QueryPages_GetAllTranslationOfPage_FluentAPI
    {
        public void QueryPages_GetAllTranslationsOfPage_FluentAPI(CultureInfo ci)
        {
            var childNodes = App.WorkWith()
           .Pages()
           .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
           .Where(p => p.GetPageData() != null && p.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Standard)
           .ThatArePublished()
           .ThatAreForLanguage(ci)
           .Get();
        }
    }
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
This Article Contains
New to Sitefinity?