More in this section

Forums / General Discussions / PageNode returns nothing

PageNode returns nothing

2 posts, 0 answered
  1. Fareed
    Fareed avatar
    5 posts
    Registered:
    11 May 2011
    14 Jul 2011
    Link to this post
    Hello,

    I am developing an application with Sitefinity 4.1 SP2. There is a scenario where I have to get Page Details so i m using GetPAgeNodes() method of PageNode class with below code

    PageNode pga = pageManager.GetPageNodes().Where(pD => pD.Title == currentAccessedPage).FirstOrDefault();

    But the above code returns NULL. I have tried with UrlName, Title and other varous ways but no luck. Nothing returns. Have gone through the existing threads of Sitefinity forum. Above method was mentioned most of time in your forums. I have also tried with fluent API, it does not return anything.

    Please help me out in this situation and how to get page details as we need to have PageId of requested Page so that we can have information for assigned permissions and Roles.
    Waiting for your response as early as possible

    Thanks
    Fareed Khan

  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    19 Jul 2011
    Link to this post
    Hi Fareed,

    Please take a look at the below examples showing how you can properly access the page details using Fluent API.
    var fluent = App.WorkWith().Pages();
                //get a page by its Title
                var mypage = fluent.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
                                         .Where(p => p.Page.Title == "Test").Get().FirstOrDefault();
     
                //get the id of that page
                var pageId = mypage.Id;
                //get a list of pageNodes
                var pageNodes = App.WorkWith().Pages().Get().ToList();
                foreach (var p in pageNodes)
                {
                    //get the node id
                    var nodeId = p.Id;
                    //get the id of the page in that node
                    var myPageId = p.Page.Id;
                    //get the page UrlName
                    var myPageUrlName = p.Page.UrlName;
                    //etc..
                }
    when working with PageData in a PageNode it's good to check if  p.Page is not NULL, since group pages for instance do not have PageData object, and your code will return Null exception. Please do not hesitate to write back if you have any additional questions

    Greetings,
    Boyan Barnev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered