Querying pages by title in a multisite instance?
Is there anyway to get a page by name but only for the current site a user is in? For example, I may have a project with 3 sites, all containing the same page named "Parks". Normally I'd try to use the PageManager and get all the pages with the name Parks but it'd return 3 separate PageNodes with no obvious way to distinguish between them. Is there any way I can tell which site a queried page belongs to? Thanks
Hi,
You can filter the pages by their FrontendRootNodeId. Every site has a different FrontendRootNodeId which you can get using "SiteInitializer.CurrentFrontendRootNodeId". You can see an example code below which gets the "Home" page from the current site only.
var pageManager = PageManager.GetManager();
var test = pageManager.GetPageNodes().Where(p => p.Title ==
"Home"
&& p.RootNodeId == SiteInitializer.CurrentFrontendRootNodeId);
Wow! Worked perfectly. That really needs to be more well known. Thanks!