Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
I managed to find out how to do it. The custom content loader service should look like this:
public class CustomContentLoaderService : ContentLoaderService
{
private readonly IHttpContextAccessor _httpContextAccessor;
protected CustomContentLoaderService() : base()
{
}
public CustomContentLoaderService(IHttpContextAccessor httpContextAccessor, IContentLoader contentLoader, IPermanentLinkMapper permanentLinkMapper, IContentProviderManager providerManager) : base(contentLoader, permanentLinkMapper, providerManager)
{
_httpContextAccessor = httpContextAccessor;
}
protected override bool ShouldContentBeExposed(IContent content)
{
if (_httpContextAccessor.HttpContext.Request.Query.TryGetValue("draft_content", out var _))
{
return true;
}
return base.ShouldContentBeExposed(content);
}
}
Hi Eric
ContentLoadedService has been moved to an Internal namespace now. So is there a workaround for these classes that alow us to skip calling internal namespaces directly and avoid future code breakages? Or should we request for these to be moved to public API instead?
Regards
Ritu
Hi. I want to fetch the draft content to be able to preview before publishing.
I've tried using this approach: https://docs.developers.optimizely.com/content-management-system/v1.5.0-content-delivery-api/docs/customizing-content-delivery-api-for-edit-view
However, that code is for CMS 11(?).
When I registered my custom ContentLoaderService, a completely empty one that just overrides ContentLoaderService, I get a generic 500 response for whatever content I try to fetch 😞.