Try our conversational search powered by Generative AI!
AI OnAI Off
Here you have two extension methods. You could easily change them to use contentlink instead of IContent if you feel like:
public static int SiteIdAsInt(this IContent content) { var definition = ServiceLocator.Current.GetInstance<SiteDefinitionResolver>().GetDefinitionForContent(content.ContentLink, false, false); if (definition == null) { return -1; } return definition.StartPage.ID; } public static Guid SiteIdAsGuid(this IContent content) { var definition = ServiceLocator.Current.GetInstance<SiteDefinitionResolver>().GetDefinitionForContent(content.ContentLink, false, false); if (definition == null) { return Guid.Empty; } return definition.Id; }
Is there a way to filter DataFactory.Instance.GetReferencesToContent on sites? E.g. we want only to get references on the same site as the user visits.
We have a multisite solution and I've tried to fetch a SiteDefinition or a startpage or anything that I can compare to the original reference but haven't found any way of doing that. Haven't found a way of getting a SiteDefinition from either ContentReference, PageData or any other object. Feels weird that it should be so difficult so I have a feeling that I'm missing something.