SF 5.1 - get PageNode from URL

Posted by Community Admin on 04-Aug-2018 14:50

SF 5.1 - get PageNode from URL

All Replies

Posted by Community Admin on 18-Sep-2012 00:00

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!

Posted by Community Admin on 18-Sep-2012 00:00

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 :
site.com/.../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!

This thread is closed