More in this section

Forums / Developing with Sitefinity / SF 5.1 - get PageNode from URL

SF 5.1 - get PageNode from URL

2 posts, 0 answered
  1. Olivier
    Olivier avatar
    31 posts
    Registered:
    06 Aug 2012
    18 Sep 2012
    Link to this post
    I am trying to figure out how I can get a PageNode from a URL.  I can only find things that relate to SF3.7.  Namepsaces have changed since then, and functionality changed a lot as well so things are not applicable anymore.

    Would someone have an example on this?

    Thanks!
  2. Olivier
    Olivier avatar
    31 posts
    Registered:
    06 Aug 2012
    18 Sep 2012
    Link to this post
    Finally found how.
    In case someone else is trying to find this, here is how :
    PageNode node = pageManager.GetPageNodes().Where(pN => pN.UrlName == yourURL).FirstOrDefault();
        if (node != null)
        {
            ...do something...
        }
    If the page for which you have the url is something like this :
    http://site.com/Section/This-is-the-page
    or
    ~/Section/This-is-the-page,
    just make sure that the UrlName parameter for the command is just the page name : This-is-the-page as in the above examples.  Don't include folders, ~, or / in the UrlName string.
    At least, this is what worked for me.

    Hope it helps someone!

2 posts, 0 answered