I have tried to create proxy properties that display the VisibleInMenu property like so.
public virtual bool ShowInNavigation {
get {
var show = this.GetPropertyValue(p => p.VisibleInMenu);
return show;
}
set { this.SetPropertyValue(p => p.VisibleInMenu, value); }
}
But they all show "null" even though value is true or false.
I guess there should be a simpler solution but this was my solution.
I can actually find properties that randomly dissapear now.
I add them manually here:
[ServiceConfiguration(typeof(IContentModelMapper), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomContentModelMapper : DefaultContentConverter
{
public CustomContentModelMapper(IContentTypeRepository contentTypeRepository,
ReflectionService reflectionService,
IContentModelReferenceConverter contentModelService,
IContentVersionRepository contentVersionRepository,
ContentLoaderService contentLoaderService,
UrlResolverService urlResolverService,
ContentApiConfiguration apiConfig,
IPropertyConverterResolver propertyConverterResolver)
: base(contentTypeRepository,
reflectionService,
contentModelService,
contentVersionRepository,
contentLoaderService,
urlResolverService,
apiConfig,
propertyConverterResolver)
{
}
public override int Order => 200;
protected override ContentApiModel CreateDefaultModel(IContent content)
{
var baseModel = base.CreateDefaultModel(content);
if (content is SitePageData sp)
{
base.AddToPropertyMap(baseModel.Properties, nameof(sp.MetaKeywords), new StringPropertyModel(new PropertyString(string.Join(", ", sp.MetaKeywords))));
base.AddToPropertyMap(baseModel.Properties, nameof(sp.VisibleInMenu), new BooleanPropertyModel(new PropertyBoolean(sp.VisibleInMenu)));
}
return baseModel;
}
}
Hi,
Im trying to implement the content delivery api and it's going pretty well.
Sofar i've managed to create an app that builds a menu and can fetch pages with blocks on navigation.
However I've not been able to identify how to exclude/filters items that have the "Display in navigation" property set to false. Normally I can check the VisibleInMenu property to reflect this value.
In the content api this property is not exposed either in the content or children call. How can I find it? Or do I manually have to implement some kind of global filter that excludes this for all calls?
Preferrably I would like to see it on the /children call of my content.