Søren Mastrup
05/05/2026, 7:56 AMUmbracoHelper extensively.
I remember it being considered a big no-no in older versions of Umbraco because of its impact on performance. Is this still the case in versions 13 and above?Ravi
05/05/2026, 2:50 PMpublic IEnumerable<IPublishedContent> GetPagesOfType(string contentType)
{
var contentCache = _contextFactory.EnsureUmbracoContext().UmbracoContext.Content;
var nodes = new List<IPublishedContent>();
if (contentCache != null)
{
var publishedContent = GetHomePage();
//get this to work and we are good
if (_navigationQueryService != null)
{
_navigationQueryService.TryGetDescendantsKeysOfType(publishedContent.Key, contentType, out IEnumerable<Guid> initialDescendantsKeysOfType);
List<Guid> initialDescendantsOfTypeList = initialDescendantsKeysOfType.ToList();
if (initialDescendantsOfTypeList != null)
{
foreach (var itemKey in initialDescendantsOfTypeList)
{
var pubContent = contentCache.GetById(itemKey);
if (pubContent != null)
{
nodes.Add(pubContent);
}
}
}
}
}
if (nodes != null && nodes.Any())
{
return nodes;
}
return Enumerable.Empty<IPublishedContent>();
}
and I've done variations on a theme get sitesetting page.. I'm sure I have a version where it works in multisite here you pass and i id , and i make sure its with relative content path etcRavi
05/05/2026, 2:51 PMRavi
05/05/2026, 2:52 PMpublic IPublishedContent? GetHomePage()
{
var contentCache = _contextFactory.EnsureUmbracoContext().UmbracoContext.Content;
IPublishedContent? publishedContent = null;
if (_navigationQueryService.TryGetRootKeysOfType(HomePage.ModelTypeAlias, out var rootKeys))
{
publishedContent = contentCache.GetById(rootKeys.FirstOrDefault());
}
return publishedContent;
}skttl
05/05/2026, 3:52 PMGet<ContentModels.Whatever>(), and then its cached per request 🙂Mike Chambers
05/05/2026, 5:17 PMRavi
05/05/2026, 8:39 PM