Using Fluent API to see check if current page is homepage
Hi,
Hello Webinsite,
You can use
PagesConfig conf =
new
PagesConfig();
var id = conf.HomePageId;
Thanks Ivan for such a speedy response.
public
bool
isHomepage()
SiteMapNode currentNode = SiteMapBase.GetCurrentProvider().CurrentNode;
PageSiteNode node = (PageSiteNode)currentNode;
PagesConfig conf =
new
PagesConfig();
if
(node.PageId == conf.HomePageId)
return
true
;
return
false
;
Hello Webinsite,
This code should be siffucient.
Regards,
Radoslav Georgiev
the Telerik team
Hi Ivan,
Sadly, I didn't have as much luck with this code, the following code always seems to output an empty Guid, 00000000-0000-0000-0000-000000000000
PagesConfig pageConfig =
new
PagesConfig();
Response.Write(pageConfig.HomePageId.ToString());
<
pagesConfig
homePageId
=
"fcf21816-64c5-4890-8bee-146dc3fceb31"
defaultFrontendTemplateId
=
"7aee4a2a-1d1e-4a03-97bb-2159e6a71bae"
xmlns:config
=
"urn:telerik:sitefinity:configuration"
xmlns:type
=
"urn:telerik:sitefinity:configuration:type"
config:version
=
"4.0.910.0"
/>
PagesConfig pageConfig =
new
PagesConfig();
Response.Write(pageConfig.DefaultFrontendTemplateId.ToString());
// Outputs : f669d9a7-009d-4d83-bbbb-000000000003
Hi Haydn,
There is a method in PageFacade called - SetAsHomePage() which we use and it explicitly sets the homepage id to the configuration. You can perform the following query
var configManager = Config.GetManager();
var config = configManager.GetSection<PagesConfig>();
var id = config.HomePageId;
Thanks Ivan,
That seems to work :)
Kind Regards
Haydn