How to returnt he Current Page using the API ?

Posted by Community Admin on 03-Aug-2018 16:56

How to returnt he Current Page using the API ?

All Replies

Posted by Community Admin on 25-Nov-2010 00:00

Hi

I am a newbie to the SF API and was wondering how I get the current SF content page in code. Specifically, I want to :

1. Get the Current Page
2. Get its Category
3. Use that category to perform another query against our DB... (I am mapping products to the taxonomy, so that if you change the taxonomy for the page, this will change the products that are displayed.

Any ideas ?

Cheers
Mark

Posted by Community Admin on 26-Nov-2010 00:00

Hello Mark,

Thank you for contacting Telerik Support.

You can use the bellow code snippet to get the currently viewed page:

public PageNode GetCurrentPage()
    SiteMapNode currentNode = SiteMapBase.GetCurrentProvider().CurrentNode;
    PageSiteNode node = (PageSiteNode)currentNode;
    return App.WorkWith().Pages().Where(p => p.UrlName == node.UrlName).Get().FirstOrDefault();


Please note that in design mode this will return null.

Best wishes,
Radoslav Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed