November Happy Hour will be moved to Thursday December 5th.

Retrieve siteId and siteName for a PageData instance

Vote:
 

Hi!

Previously one could get siteId and siteUrl for a specific PageData instance in a multisite enterprise environment with following code:

var siteId = DataFactory.Instance.GetSettingsFromContent(page.ContentLink).Parent.SiteId;
var siteUrl = DataFactory.Instance.GetSettingsFromContent(content.ContentLink).SiteUrl;

    

But well, guess that's now out of the question. Is there a clean way to get SiteDefinitions for a specific PageData instance?

#82604
Mar 16, 2014 17:29
Vote:
 
var resolver = ServiceLocator.Current.GetInstance<SiteDefinitionResolver>();
var site = resolver.GetDefinitionForContent(page.ContentLink);
var siteId = site.Id;
var siteUrl = site.SiteUrl;

    

#82605
Mar 16, 2014 19:41
Vote:
 

Thank you, Valdis!

#82609
Mar 16, 2014 23:00
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.