How to detect current note is set to home?

Posted by Community Admin on 03-Aug-2018 18:46

How to detect current note is set to home?

All Replies

Posted by Community Admin on 20-Dec-2010 00:00

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

Posted by Community Admin on 20-Dec-2010 00:00

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

Posted by Community Admin on 20-Dec-2010 00:00

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! 

Posted by Community Admin on 23-Dec-2010 00:00

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

Posted by Community Admin on 28-Dec-2010 00:00

Thanks Ivan. It solved my problem.

This thread is closed