Get the HomepageId
Hi,
I normally use this code to get the HomepageId from the config:
var homePageId = Config.Get<PagesConfig>().HomePageId;
var homePageId = Config.Get<PagesConfig>().HomePageId;
var homeId = Config.Get<ProjectConfig>().DefaultSite.HomePageId;
Thanks Stephen2,
I also noticed this second option, but it returns an empty Guid anyways.
@Sitefinity Team: could you let us know what method or property we can use to get this Id? I'm using Sitefinity 5.2. A fresh started project.
Thanks,
Daniel
Hi,
I tried to reproduce this problem locally and the method is really returning an empty Guid.
This is now a deprecated way to get the Id. So, to get the job done I recommend you using the following:
var site = SystemManager.CurrentContext.CurrentSite;
var homePageId = site.HomePageId;
Ivaylo,
I noticed that the SystemManager.CurrentContext.CurrentSite returns an object of type Telerik.Sitefinity.Multisite.MultisiteContext.SiteProxy. This object does contain the HomePageId property, but if you are using the MultisiteManager and calling the function GetSite() you will get an object type "Telerik.Sitefinity.Multisite.Model.Site".
Any idea how to get a list of all sites with the HomePageId property?
Thanks,
Craig