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.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.