More in this section

Forums / General Discussions / How to detect current note is set to home?

How to detect current note is set to home?

5 posts, 1 answered
  1. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    20 Dec 2010
    Link to this post
    Hi,

    My challenge is to programatically detect whether the current node is set to home. I'm developing a custom control and I need that to behave differently in the pages set as Home under different page groups. A quick response would be highly appriciated.

    Thanks,
    Duneel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Dec 2010
    Link to this post
    Hi Duneel,

    You can get the current SiteMapNode and compare its id to the home page id

    PageSiteNode result = null;
    SiteMapProvider provider = SiteMapBase.GetCurrentProvider();          
    result = provider.CurrentNode as PageSiteNode;

    To get the current home page ID you can use the code below

    var homePageId = Config.Get<PagesConfig>().HomePageId;


    Best wishes,
    Ivan Dimitrov
    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
  3. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    20 Dec 2010
    Link to this post
    Hello Ivan,

    Thank you very much for the instructions. Using the sample code provided I can find the ID of the Home page. Now I have another problem. I was thinking each sub division (page group) can have it's own home page. but later found that there can be only one home page withing the whole instance.

    Now the challenge is to identify the default landing page of a page group. Can I programatically detect if the page is the default landing page of a page group? The website I'm developing has 4 sub sites (seperated by page groups having it's own landing group).

    Thanks,
    Dunee! 
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Dec 2010
    Link to this post
    Hi Duneel,

    If the current page has parent page which does not have PageData, then this page is the first landing page of the page group. You can check this post

    Greetings,
    Ivan Dimitrov
    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
    Answered
  5. Duneel
    Duneel avatar
    166 posts
    Registered:
    08 Dec 2010
    28 Dec 2010
    Link to this post
    Thanks Ivan. It solved my problem.
5 posts, 1 answered