+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Querying pages by title in a multisite instance?

Querying pages by title in a multisite instance?

3 posts, 1 answered
  1. J
    J avatar
    10 posts
    Registered:
    18 May 2015
    15 Jul 2015
    Link to this post
    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
    Answered
  2. Velizar Bishurov
    Velizar Bishurov avatar
    143 posts
    Registered:
    01 Dec 2016
    20 Jul 2015
    Link to this post
    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
     
  3. J
    J avatar
    10 posts
    Registered:
    18 May 2015
    20 Jul 2015 in reply to Velizar Bishurov
    Link to this post
    Wow! Worked perfectly. That really needs to be more well known. Thanks!
3 posts, 1 answered