Querying pages by title in a multisite instance?

Posted by Community Admin on 04-Aug-2018 21:55

Querying pages by title in a multisite instance?

All Replies

Posted by Community Admin on 15-Jul-2015 00:00

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

Posted by Community Admin on 20-Jul-2015 00:00

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);

Regards,
Velizar Bishurov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 20-Jul-2015 00:00

Wow! Worked perfectly. That really needs to be more well known. Thanks!

This thread is closed