More in this section

Forums / General Discussions / How to returnt he Current Page using the API ?

How to returnt he Current Page using the API ?

2 posts, 0 answered
  1. Mark
    Mark avatar
    19 posts
    Registered:
    10 Nov 2008
    25 Nov 2010
    Link to this post
    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
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Nov 2010
    Link to this post
    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
2 posts, 0 answered