as the name suggests I would like to get epi to recurse part of the page tree. basically to have a particular page type work like its a content area, but expanding its children rather than items in a contentArea.
this is for recursing the navigation, which we have implemented as page types, rather than nested contentAreas, as this makes it considerably easier to deal with for the editors.
I tried extending the contentModelReference / ContentReferencePropertyModel - and overriding the extractexpandedvalue, but that only returns a single ContentApiModel - and I would ideally like to only have to expand a single level at a time, and let Epi pick up the next level by finding another reference - seeing that it wants expanding in the same fashion and doing so using the same code for the previous level
I also tried extending the CollectionPropertyModelBase, but that only wants a Long string as the base for the type, rather than a contentreference.
basically I am going around in circles.
is there an easy way to acheive this?
If I understood you correctly, this is a fairly common thing to do in any CMS. Luckely Optimizely as a reference site you can use to pick examples from: https://github.com/episerver/Foundation/blob/main/src/Foundation/Infrastructure/Helpers/HtmlHelpers.cs#L463
GetMenuItems will resursively look at its children and call itself to build a navigation menu.
thanks for the reply, but this is for specifically the contentApi and the ContentConverters etc used when controlling serialising.
so for instance - if I have a reference to a navigation page type, I would like the serialising process to recursively serialise the current page (expanded) and continue to do so for all children of that page - all the way down.
I have had some success by doing the following - but it seems a little cumbersome.
created a IPropertyConverterProvider, which when it hits a PropertyContentReference, loads the content in and checks for its type (not particularly happy with having to do this, so may try to create a specific contentreference type to avoid loading in everything)this then uses a PropertyModelConverter which loads in the references to the immediate children of the current page into a PropertyContentReferenceList and passes that to a CustomContentReferenceListPropertyModel, which explicitly calls expand and uses the ContentConvertingService to expand each of those in the overridden ExtractExpandedValue method.
I then have a NavigationPageConverter which sets a Children property (which is set to ScaffoldColum(false) to avoid it showing in the editor) to the list of these child references and the process recurses its way down, using the standard GetCustomProperties of the DefaultConverter, which in turn calls the PropertyConverter for the next level down.
feels like I am loading in the content more than once though
Forgive me, I didn't pay proper attention to your original post. Can I just ask the intent of what you are trying to resolve? Are you attempting to get a list of children recursively until you to get end but making it happen with a single call to the content delivery api ?
Is calling <contentguid>/children?select=contentlink multiple times and then caching the results out of the question?
this is to include the navigation with a request for a page in the cms, dont want to have to make a seperate call (or multiple seperate calls really)
have a reference to the root of the navigation - would like that to expand its way down such that the navigation page information is included in each page request.
currently I have done the following - which isnt really ideal I know.
ContentPropertyConverterProvider for a PropertyContentReference, works out its pointing to a navigation page
calls a CustomPropertyContentReferenceConverter, which returns a ContentReferenceListPropertyModel - with the children loaded in by hand
call expand on this such that the page info is expanded - having overridden the ExtractExpandedValue method
default converter picks this up and it continues around to expand the whole navigation.